pandas Seaborn pairplot ValueError:范围参数中的最大值必须大于最小值
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/47416605/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Seaborn pairplot ValueError: max must be larger than min in range parameter
提问by yan
I am getting this error while plotting pairplot using seaborn library in Python. With reference to the previous questions asked on the same topic, I cleaned my data and verified if I have any null value,
在 Python 中使用 seaborn 库绘制 pairplot 时出现此错误。参考之前就同一主题提出的问题,我清理了我的数据并验证了我是否有任何空值,
train_data.isnull().values.any()
Out[91]: False
import seaborn as sns
sns.pairplot(train_data)
I am still getting this Value Error for a seaborn plot. I am not sure apart from cleaning data, what else we can do to avoid this error. Adding more information about the data, I have total 81 columns and around half a million rows. I dropped a row having all null values and not remaining data is null free. Now question is how to proceed with this error. Any suggestions?
对于 seaborn 情节,我仍然收到此值错误。除了清理数据,我不确定我们还能做些什么来避免这个错误。添加有关数据的更多信息,我总共有 81 列和大约 50 万行。我删除了一行具有所有空值并且没有剩余数据是空的。现在的问题是如何处理这个错误。有什么建议?
采纳答案by Harry_pb
I received the same error. I would suggest you to work on several things. First, check if you have string
data type and either convert it to float
or not add for pairplot
, slice up your dataset and then work in it. I actually mean, dimensional reduction
. 81 columns may not be the best choice to experiment. As you mentioned you have half a million rows and 81 columns. First try on smaller dataset and then go for larger one. Seaborn plot sometimes fails to accommodate so many rows and columns on local systems. If you try on some cluster with larger RAM, it might work fine but this error is not new. Try working on
我收到了同样的错误。我建议你做几件事。首先,检查您是否有string
数据类型,并将其转换为float
或不添加 for pairplot
,对数据集进行切片,然后对其进行处理。我的意思是,dimensional reduction
。81 列可能不是实验的最佳选择。正如您所提到的,您有 50 万行和 81 列。首先尝试较小的数据集,然后再尝试较大的数据集。Seaborn 图有时无法在本地系统上容纳如此多的行和列。如果您尝试使用较大 RAM 的某个集群,它可能会正常工作,但此错误并不新鲜。尝试工作
exp = test_data[0:10][:1000]
sns.pairplot(exp)
Before applying this, first remove all string columns and experiment only on float
, int
value columns. I hope this helps.
在应用此之前,首先删除所有字符串列并仅对float
,int
值列进行实验。我希望这有帮助。
回答by abhishek khandelwal
Your dataframe might have NaN values. Remove those rows or replace NaN with 0 and it should work.
您的数据框可能具有 NaN 值。删除这些行或用 0 替换 NaN ,它应该可以工作。
回答by Taras P.
You need removed all NaN values in oririn DataFrame. Use method df.dropna()
您需要删除 oririn DataFrame 中的所有 NaN 值。使用方法df.dropna()
回答by brainhack
Faced the same issue, df.fillna()doesn't replace values with NaNin our dataframe. Kindly use the df.replace(np.nan, your_value).
面对同样的问题,df.fillna()不会在我们的数据框中用NaN替换值。请使用df.replace(np.nan, your_value)。