Python Forum
Data dtype error according to the rule "safe"
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Data dtype error according to the rule "safe"
#1
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!
Reply
#2
I just run your code without any problem seaborn v. 0.9.0, pandas v.0.25.1.
Reply
#3
Thanks for the reply. I guess it's a system / pycharm error, but I just can't figure it out :(
Reply
#4
(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.
Reply
#5
@chedge, unfortunately still not. I ended up running my regressions on Spyder.
Reply
#6
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  FutureWarning: Logical ops (and, or, xor) between Pandas objects and dtype-less seque NewBiee 5 1,566 Sep-12-2023, 03:15 PM
Last Post: deanhystad
  dtype in not working in mad() function ift38375 8 3,915 Jul-22-2019, 02:53 AM
Last Post: scidam
  ValueError: Input contains infinity or a value too large for dtype('float64') Rabah_r 1 12,880 Apr-06-2019, 11:08 AM
Last Post: scidam
  numpy dtype anomaly bluefrog 4 3,494 Nov-07-2018, 12:37 AM
Last Post: bluefrog
  interp2d casting ruled not 'safe' sebseb 0 1,849 Jul-05-2018, 09:21 AM
Last Post: sebseb

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020