Skip to content

Instantly share code, notes, and snippets.

@yheihei
Last active January 7, 2022 09:30
Show Gist options
  • Save yheihei/50881544d56761c3d7028a71759a3539 to your computer and use it in GitHub Desktop.
Save yheihei/50881544d56761c3d7028a71759a3539 to your computer and use it in GitHub Desktop.
行と列指定でデータフレームの値を取得する
import pandas as pd
df = pd.read_csv("sample.csv")
df
# 名前 メールアドレス
# 0 小久保 yheihei0126@gmail.com
# 1 ちゃた chataro@gmail.com
print(df.at[0, '名前'])
# 小久保
# こうやって検索して出すこともできる
result_df = df[df['名前'] == '小久保'].iloc[0]
print(result_df['メールアドレス'])
# yheihei0126@gmail.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment