0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

pythonで読み込んだCSVデータから集計値を取得する

Posted at

目的

こんなCSVデータを読み込んだ時に
image.png
列データの合計(値段の場合500+400+600=1500)を出力する方法

環境

jupyter notebook
python

  • CSVを読み込んで変数(例;sample_data)に入れる
import pandas as pd
sample_data = pd.read_csv("サンプルデータ.csv", encoding="shift_JIS")
  • 変数["集計したい列名"].sum() で合計値が出力される
sample_data["値段"].sum()

image.png

  • 文字が入っている列の場合、文字が結合されて出力される。
sample_data["種類"].sum()

image.png

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?