0
0

Python実践データ分析100本ノック第2版トライ中

Last updated at Posted at 2024-09-11

ノック25とノック27でエラー出現

google colaboratoryでやってますが、ノック25と27でエラー出現。

まずノック25

ノック25は辞書を使って以下の様に書き換えたら、何とかエラーが消えました。

# 'count'列を数値型に変換する
uselog_months['count'] = pd.to_numeric(uselog_months['count'], errors='coerce')

# 'customer_id'ごとに集計(教科書の答えではエラーが出て上手くrunできないので、辞書を使ってみた。)
uselog_customer = uselog_months.groupby('customer_id').agg({'count': ['mean', 'median', 'max', 'min']})
uselog_customer = uselog_customer.reset_index(drop=False)
uselog_customer.head()

次はノック27

教科書通りだとエラーが出て実行できない。
どうやらpandasのバージョンが違うみたいで、先に以下のコードでpandasを指定すると上手く動きました。

!pip install pandas==1.3.5

でもpandasバージョンだいぶ違うし、補足でもいいから新しいコードをネットに上げて欲しいです。
(表記法も少し変わってるのかな?)

PS

結局anaconda3でpandas等のバージョンを指定して環境を作成し、秀和システム実践データ分析100本ノック第2版を続けることにしました。変なエラーが今のところ出現しないので精神衛生上好ましいです。でも文法とか変わってたら勉強したこと無駄になりそうです。それにしてもgoogle colaboratoryの補完機能素晴らしかったです。

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