前提・実現したいこと
Excelの自動化
集計表の作成
発生している問題・エラーメッセージ
Could not import the lzma module. Your installed Python is incomplete. Attempting to use lzma compression will result in a RuntimeError.
warnings.warn(msg)
該当のソースコード
Python
import pandas as pd
df = pd.read_excel("店舗別売上リスト.xlsx",sheet_name="統合表")
shopDictionary = {}
total = 0 #全店舗の売上を保存する変数
for index,rows in df.iterrows():
if rows["店名"] not in shopDictionary:
shopDictionary[rows["店名"]] = rows["売上金額"]
else:
shopDictionary[rows["店名"]] = shopDictionary[rows["店名"]] + rows["売上金額"]
total = total + rows["売上金額"]
shopDictionary["全店合計"] = total
df2 = pd.DataFrame(list(shopDictionary.items()),columns=["店名","売上合計"])
with pd.ExcelWriter("店舗別売上集計リスト.xlsx",date_format='YYYY/MM/DD',datetime_format='YYYY/MM/DD') as writer:
df2.to_excel(writer, sheet_name="集計表",index=False)
試したこと
補足情報(FW/ツールのバージョンなど)
Mac OS catalina
Python 3.8.6
VScode
pyenvでインストール
回答1件
あなたの回答
tips
プレビュー