Created
August 9, 2022 02:17
-
-
Save AkiyonKS/57c6cfe19bbc06421a7a46e846780310 to your computer and use it in GitHub Desktop.
extract Japanese companies from trains
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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