LoginSignup
0
0

More than 1 year has passed since last update.

グラフが描画できない:ConversionError: Failed to convert value(s) to axis units

Posted at

ConversionError: Failed to convert value(s) to axis units:

seabornでグラフを描出しようとした際に、このエラーが出て困ったので解決策を備忘録的に記載しておく。
結果から言うと、描画したい変数にobjectとfloat(nan)が混在していたことが原因だった。

import matplotlib.pyplot as plt
import seaborn as sns

# 描画したい変数がobject型の時
# dfはデータフレーム、VARIABLEは描画したい変数、'XNA'は適当な欠損値を表す文字列
df.VARIABLE.fillna('XNA') # float型の欠損値をobject型に置換
sns.histplot(df, x=VARIABLE) # 描画

うまくグラフが出力できない時はデータ型を詳しく確認するべき。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0