Home > OS >  Plots from excel with panda and seaborn 'ufunc 'isfinite' not supported for the input
Plots from excel with panda and seaborn 'ufunc 'isfinite' not supported for the input

Time:12-21

I am trying to configure a template for creating plots for my test data. Therefore I need to say I am pretty new to that in python, and I already googled quite a lot regarding my question but what I found could not help me. I have a excel table with data in two columns, which I want to plot against each other. My code looks as follows

file='C:/Documents/Test/test_file.xlsx'
df1=pd.read_Excel(file,sheet_name='sheet1',header=0, engine="openpyxl")
plt.figure()
sns.lineplot(data=df1[:,:],x="eps",y="sigma",sort=False,linewidth=0.8)

The excel has -as mentioned a header with eps and sigma as x and y values. The values following are floats, when I check the datatype with df1.dtypes, the result is 'float64' So has anyone an idea what is not working? I get the error 'ufunc 'isfinite' not supported for the input types'

Plotting data from excel with panda and seaborn against each other and save the image.

CodePudding user response:

This might be a library issue. I've been running into the same problem with example datasets and even a very simple:

sns.lineplot(x=[1], y=[1])

I'll update if I find a solution.

Edit: There seems to be an issue with Numpy that is causing this issue with Seaborn. Solution is to downgrade Numpy to 1.23 until 1.24.1 is released.

https://github.com/mwaskom/seaborn/issues/3192

CodePudding user response:

I have not enough reputation to comment so I will leave it as a reply. Try removing NaNs from your dataset before plotting because float64 columns can store np.nan and some plotting functions may complain.

Welcome to SO Gash Guri!

  • Related