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?

excel 既にあるデータを調べたい

Posted at

概要

調べたい たくさん : pandas

調べたい 少し : openpyxl

pandas

import pandas as pd

# CSVファイルを読み込む
df = pd.read_csv('sales_data.csv')

# 売上が1000以上のデータを探索
result = df[df['売上'] >= 1000]
print(result)

openpyxl

売上 : 1000円以上のもの探す
import openpyxl

# Excelファイルを開く
wb = openpyxl.load_workbook('sales_data.xlsx')

# シートを指定
sheet = wb['Sheet1']

# 売上が1000以上の行を探す
for row in sheet.iter_rows(min_row=2, max_row=sheet.max_row, min_col=1, max_col=2):
    # ここでは2列目が売上データと仮定
    if row[1].value >= 1000:  # row[1]は売上列
        print(f"商品: {row[0].value}, 売上: {row[1].value}")

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?