Seaborn lineplot, TypeError: ufunc 'isfinite' not supported for the input types
Question:
I am getting the following error when trying to plot a lineplot with seaborn.
TypeError: ufunc 'isfinite' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
Minimal example reproducing error:
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
dataset = {
"x": [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],
"y": [1.0, 2.3, 4.5, 1.2, 3.4, 5.3, 1.1, 2.4, 3.6, 1.1, 3.3, 5.3],
"id": ["a", "a", "a", "b", "b", "b", "a", "a", "a", "b", "b", "b"],
"seed": [0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1],
}
df = pd.DataFrame(data=dataset)
print(df.dtypes)
g = sns.lineplot(data=df, x="x", y="y", hue="id", errorbar="sd")
plt.show()
plt.close()
I have tried checking the datatypes of all inputs and Dataframe columns, and changing "id" to be an integer type (even though that is not my goal) and the error persists.
Answers:
aparently there is a version issue going on
fix
Numpy 1.24.0 has a bug that causes an exception within several seaborn functions. The bug has been fixed and numpy has released a new version to address it. The solution is to install numpy 1.24.1 the same way that you installed numpy 1.24.0.
I am getting the following error when trying to plot a lineplot with seaborn.
TypeError: ufunc 'isfinite' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
Minimal example reproducing error:
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
dataset = {
"x": [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],
"y": [1.0, 2.3, 4.5, 1.2, 3.4, 5.3, 1.1, 2.4, 3.6, 1.1, 3.3, 5.3],
"id": ["a", "a", "a", "b", "b", "b", "a", "a", "a", "b", "b", "b"],
"seed": [0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1],
}
df = pd.DataFrame(data=dataset)
print(df.dtypes)
g = sns.lineplot(data=df, x="x", y="y", hue="id", errorbar="sd")
plt.show()
plt.close()
I have tried checking the datatypes of all inputs and Dataframe columns, and changing "id" to be an integer type (even though that is not my goal) and the error persists.
aparently there is a version issue going on
fix
Numpy 1.24.0 has a bug that causes an exception within several seaborn functions. The bug has been fixed and numpy has released a new version to address it. The solution is to install numpy 1.24.1 the same way that you installed numpy 1.24.0.