This question has been asked in many threads and has worked for others, but not for me. I am trying to convert object
data type into int
to perform a group by aggregation.
Following are what I tried and the errors I got so far, (I am using python 3)
According to this link, I tried these two:
df['my_var'] = df['my_var'].astype(str).astype(int)
df['my_var'] = df['my_var'].astype(int)
Same error for both:
ValueError: invalid literal for int() with base 10: '*'
And then I tried,
df['my_var'] = pd.to_numeric(df['my_var'])
I got an error:
ValueError: Unable to parse string "*" at position 6116
This is how dtypes
looks like,
print (df.dtypes)
my_var object
dtype: object
I know some of the similar questions are down voted, however, I did not succeed using those answers. Is it a version error? I am finding it difficult to understand this error. Any help or suggestion would be appreciated.