Python Forum
Data dtype error according to the rule "safe" - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Data Science (https://python-forum.io/forum-44.html)
+--- Thread: Data dtype error according to the rule "safe" (/thread-24208.html)



Data dtype error according to the rule "safe" - AndreasMavro - Feb-04-2020

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!


RE: Data dtype error according to the rule "safe" - scidam - Feb-05-2020

I just run your code without any problem seaborn v. 0.9.0, pandas v.0.25.1.


RE: Data dtype error according to the rule "safe" - AndreasMavro - Feb-05-2020

Thanks for the reply. I guess it's a system / pycharm error, but I just can't figure it out :(


RE: Data dtype error according to the rule "safe" - chegde - Feb-11-2020

(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.


RE: Data dtype error according to the rule "safe" - AndreasMavro - Feb-12-2020

@chedge, unfortunately still not. I ended up running my regressions on Spyder.


RE: Data dtype error according to the rule "safe" - Pama - Feb-27-2020

A work around by JohanC is available here: https://stackoverflow.com/questions/60060301/typeerror-cannot-cast-array-data-from-dtypeint64-to-dtypeint32-accordin

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