Data type already in int but receiving error: cannot convert float infinity to integer

Viewed 23

I have a column: "Rented Bike Count" in my data frame, which is the dependent variable of my linear regression project. I found that its distribution is highly skewed, so I wanted to transform it into a more normal distribution as a data preparation step for linear regression.

enter image description here

But when I used Log transformation for the same using: sns.distplot(np.log10(temp_df['Rented Bike Count']))

It showed me the following error:

enter image description here

"Rented Bike Count" is already of int data type. Can anyone help?

1 Answers

This is speculative as no data is provided, but from the histogram you show I assume you have zero values in temp_df['Rented Bike Count']. You cannot calculate the logarithm of 0, which makes numpy return -inf (instead of throwing an error). In order to plot the data you would need to replace these infinite values first.

Related