Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
722 views
in Technique[技术] by (71.8m points)

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

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

question from:https://stackoverflow.com/questions/65881604/seaborn-typeerror-no-loop-matching-the-specified-signature-and-casting-was-foun

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

df['Multiplicity'] = df['Multiplicity'].astype(int)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...