LoginSignup
0
0

More than 1 year has passed since last update.

pandas groupby メモ

Last updated at Posted at 2023-05-30

group by でsumをしようとするとdepricatedという警告が出るので、別のやり方をstackoverflowで探したら載っていました。そして真似したら動いたのでメモ。

data = testdata.groupby(['store','cat1','cat1_desc'], group_keys=True)[['sales_amt','price_chg']].apply(lambda x: x.astype(int).sum())
  • 集計するカテゴリー:店番号、商品カテゴリー
  • 上記カテゴリーごとに集計したい値: 売上、売価変更金額

この時にlambda式の中でsumをやれば動きました。

0
0
2

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