Issue
addition | add-revised |
---|---|
6 insertions(+) | 6 |
NaN | 0 |
8 insertions(+) | 8 |
From the 'addition' column of the data frame, I created the 'add-revised' column.
df['add-revised'] = df.addition.str.extract('(\d+)')
df['add-revised'] = df['add-revised'].fillna(0)
When I attempt to do
df_new['add-revised'].mean()
It's giving me the following error
TypeError: unsupported operand type(s) for +: 'int' and 'str'
I attempted to solve the problem with
df_new['add-revised'].to_numeric()
and it's giving me the following error
AttributeError: 'Series' object has no attribute 'to_numeric'
Solution
Did you try:
df_new['add-revised'] = df_new['add-revised'].astype(int)
it works for pandas version '1.2.0'
Answered By - Bugface
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.