How do I divide elements in a single column of a python dataframe?
问题 I need to divide every element in a specific column in a Pandas DataFrame by 100. By default, the .div() function in Pandas divides all elements across all columns, and attempting to specify columns to divide leaves me with only those columns. d = { 'SYMBOL':['AAAAA','BBBBB','CCCCC'], 'ASSETS':[5, 21, 74]} data = pd.DataFrame(d,columns=['SYMBOL','ASSETS']) data = data['ASSETS'].div(100) So, starting with 0 AAAAA 5 1 BBBBB 21 2 CCCCC 74 I end up getting 0 0.05 1 0.21 2 0.74 When I want 0 AAAAA