Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Seaborn pairplot ValueError: max must be larger than min in range parameter

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,

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?

like image 258
D-hash-pirit Avatar asked Nov 21 '17 15:11

D-hash-pirit


3 Answers

Your dataframe might have NaN values. Remove those rows or replace NaN with 0 and it should work.

like image 168
abhishek khandelwal Avatar answered Nov 11 '22 08:11

abhishek khandelwal


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

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.

like image 6
Hari_pb Avatar answered Nov 11 '22 09:11

Hari_pb


You need removed all NaN values in oririn DataFrame. Use method df.dropna()

like image 4
Taras P. Avatar answered Nov 11 '22 08:11

Taras P.