pandas: convert the "object" type.
-
It's necessary to calculate the MMR, but in the dayset, the necessary "Spend's" column is relevant.
import pandas as pd
df=pd.read_csv('test_data.csv',sep=',')
metrics_cpm = df.groupby('Buyer', as_index= False).agg({'Spend': 'sum', 'Impressions': 'sum'})metrics_cpm
metrics_cpm['Cost Per Mille'] = round(metrics_cpm['Spend']/metrics_cpm['Impressions']*1000, 5)metrics_cpm
Trying to change the pole type with a team:
df['Spend'] = df['Spend'].str.replace(',','.','').astype(np.float64)
But the mistake remains, how do I make the calculation?
-
Add the parameter
decimal=','
challengepd.read_csv
that's better than doing.replace
I don't know. Of course, it's a strange situation where you and the separator of the columns and the division of the grades have the same symbol.,
but, in principle, this may be, in this case, the contents of the columns come in quotes andPandas
I can figure out where.Either if you want to change manually, you can do it.
.str.replace(',','.')
And your option..str.replace(',','.','')
Changed everything into an empty line, which eventually became meaning.NA
after changefloat
♪