Python Forum

Full Version: Data dtype error according to the rule "safe"
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello everyone,

I am trying to plot a regression from the Seaborn library in Pycharm, and unfortunately I stumble upon an error which I feel may be due to my system (I am on a Windows 10, 64-bit OS). The part of my code that causes the issue is as follows:

import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt

path = "https://s3-api.us-geo.objectstorage.softlayer.net/cf-courses-data/CognitiveClass/DA0101EN/automobileEDA.csv"
df = pd.read_csv(path)

width = 12
height = 10
plt.figure(figsize=(width, height))
sns.regplot(x="highway-mpg", y="price", data=df)
plt.ylim(0,)
plt.show()
Error:
TypeError: Cannot cast array data from dtype('int64') to dtype('int32') according to the rule 'safe'
This error also appears if I try to use the lmplot function
sns.lmplot(x="highway-mpg", y="price", data=df)
Other Seaborn functions that I have tried work properly.

Any help would be much appreciated!
I just run your code without any problem seaborn v. 0.9.0, pandas v.0.25.1.
Thanks for the reply. I guess it's a system / pycharm error, but I just can't figure it out :(
(Feb-05-2020, 08:19 AM)AndreasMavro Wrote: [ -> ]Thanks for the reply. I guess it's a system / pycharm error, but I just can't figure it out :(

Were you able to resolve this issue ? I am facing the same.
@chedge, unfortunately still not. I ended up running my regressions on Spyder.
A work around by JohanC is available here: https://stackoverflow.com/questions/6006...2-accordin

It requires editing Line 84 of Seaborn's algorithms.py file.