Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Seaborn TypeError: No loop matching the specified signature and casting was found for ufunc add when using hue

Tags:

python

seaborn

I am trying to get a jointplot using Seaborn. My dataframe has three columns and looks like this

     Sample        pT Multiplicity
0      Jet1  132.2770           31
1      Jet1  181.0730           44
2      Jet1  118.1880           32
3      Jet1  155.7290           40
4      Jet1  250.8600           25
...     ...       ...          ...
1995   Jet2  134.8610           25
1996   Jet2  192.9830           58
1997   Jet2  176.5910           33
1998   Jet2   60.8583           29
1999   Jet2  158.0140           54

When I try to use the following line sns.jointplot(x="pT", y="Multiplicity", hue="Sample", data=df)

I encounter the error TypeError: No loop matching the specified signature and casting was found for ufunc add

I have tried using categorical variables, but to no avail. When I don't use the 'hue' option, I encounter no error.

The datatypes for the objects are

Sample           object
pT              float64
Multiplicity     object
dtype: object

Please help! Thanks

like image 326
user1707 Avatar asked Oct 31 '25 16:10

user1707


1 Answers

There is no any issue in your code. But your dtype of Multiplicity must be int64.

df['Multiplicity'] = df['Multiplicity'].astype(int)
like image 66
Prakash Dahal Avatar answered Nov 03 '25 08:11

Prakash Dahal