Python: Error when trying to calculate correlation of data

Following the tutorial, I try to calculate the correlation of the data but it gives me an error I can’t seem to fix. Is there anyone who can help with this? Thanks in advance.

sales = pd.read_csv(
    'data/sales_data.csv',
    parse_dates=['Date'])

corr = sales.corr()

corr

ValueError: could not convert string to float: ‘2013-11-26’
Python Data Analysis course

I think you might be referencing the wrong column in your table by accident. The error is telling you that you can’t convert the string ‘2013-11-26’ to a float. To think about it simply, a float can’t be of the format ‘2013-11-26’, since that is a date, containing things like hyphens, while a float is just a decimal number of the form x.yz.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.