ValueError: Unable to parse string '2020-03-14' at position 0

I got a value error while running this code on week 11, data visualization. I am attaching the screen short of error

df = df.apply(pd.to_numeric)

Its because date column has hyphen in it due to which it is unable to cast it to numeric. Either replace the hyphen with an empty string or use pd.to_datetime() method to convert it to datetime format.

can you explain me how to replace the hypen with the space

while executing code given by you shows error called type error and says

to_determine() missing 1 required positional argument: ‘arg’

1 Like

Set the “dateymd” column to timestamp ( shown in the videos, use the function pd.to_date() ) but this column is i guess by default a time stamp. After that, you’ll have to set the date column to index, and then delete it( using the drop function and using inplace=True). Also drop the “date” column( there are 2 date columns in the data). Then apply this to_numeric_ function

x = “19-10-1999”

x = x.replace("-"," ") # =>This will help you since string is immutable we rewrite it.

I am also getting the same error. but how did he executed that without the error(in video)

I am also getting the same error. can anyone explain to me how to overcome this error, to proceed further, got stuck in this!

‘2020-03-14’ is a date not a number so ‘pd.to_numeric’ won’t work on it.

You will need to use some other function for e.xample ‘to\_datetime’
Screenshot 2020-12-08 at 9.49.34 PM

But, you also need to think if the function you are applying ( either ‘to_numeric’ or ‘to_datetime’ )can be applied to whole dataframe or not.

When the lecture was done, i guess there was only one date column. Now the date has changed and we have 2 date column (date, dateymd). So we have to drop either one and then convert the other one to datetime. = pd.to_datetime(

df.drop(‘dateymd’ ,axis =1, inplace = True)

1 Like

Thank you for your wonderfull suggestion