Reputation: 10656
I am trying to convert data type to inter in python
when I do
df1.dtypes
I get this:
max object
I need to convert df1['max'] to int
when I do this:
df1["max"]=df1['max'].astype(int)
I get this error:
ValueError: invalid literal for long() with base 10: '312.72857666015625'
I tried to round the max before converting like this:
df1[['max']] = df1[['max']].apply(lambda x: pd.Series.round(x, 2))
I get this error:
TypeError: ("can't multiply sequence by non-int of type 'float'", u'occurred at index max')
is there an easy way to do this in pyton pandas?
Upvotes: 0
Views: 101
Reputation: 323386
If you just want to convert the str
to int
s.astype(float).astype(int)
Out[213]:
0 312
dtype: int32
Upvotes: 2