Pythonのエラーについて質問です。
いろいろ調べてみたのですが以下のコードに対してのエラー解決ができません。
解決方法を教えていただけませんでしょうか?
エラー
TypeError: Only valid with DatetimeIndex, TimedeltaIndex or PeriodIndex, but got an instance of 'Index'
コード
import matplotlib.pyplot as plt
import seaborn as sns
plt.figure(figsize=(20,5))
g = sns.barplot(x="created_at", y="id", data=df_tweet.set_index("created_at").resample("H")["id"].count().reset_index())
labels = g.get_xticklabels()
g.set_xticklabels(labels, rotation=90)
plt.show()
df_tweet
が未定義です。おそらくjupyter-notebook
とかPythonのインタープリタ環境あたりで、以前に作って再起動していない状態のため残っているデータでしょう。df_tweet
を作成する部分も追加してみてください。