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


Messages In This Thread
Data dtype error according to the rule "safe" - by AndreasMavro - Feb-04-2020, 02:04 PM

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,587 Sep-12-2023, 03:15 PM
Last Post: deanhystad
  dtype in not working in mad() function ift38375 8 3,945 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,899 Apr-06-2019, 11:08 AM
Last Post: scidam
  numpy dtype anomaly bluefrog 4 3,502 Nov-07-2018, 12:37 AM
Last Post: bluefrog
  interp2d casting ruled not 'safe' sebseb 0 1,853 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