Skip to content

Instantly share code, notes, and snippets.

@AkiyonKS
Created August 9, 2022 02:17
Show Gist options
  • Save AkiyonKS/57c6cfe19bbc06421a7a46e846780310 to your computer and use it in GitHub Desktop.
Save AkiyonKS/57c6cfe19bbc06421a7a46e846780310 to your computer and use it in GitHub Desktop.
extract Japanese companies from trains
import pandas as pd
# 予めtrains.csvをtrains_all_country.csvに変更しておいた
# ファイル読み込み
df = pd.read_csv("../csv/trains_all_country.csv")
# 無名列削除
df = df.drop(columns=df.columns[[0]])
# 国名が日本の場合のみを抽出
df = df.loc[df.country == '日本']
# 行インデックスのつけなおしと列indexの削除
df = df.reset_index().drop(columns = "index")
# ファイル保存
df.to_csv('../csv/trains.csv')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment