import pandas as pd
df = pd.read_csv("2018.tsv", sep='\t')
grouped_df = df.groupby("id")
for id in grouped_df.groups:
d = grouped_df.get_group(id)
filename = str(id) + ".tsv"
d.to_csv(filename, sep='\t', index=False, header=False)
"""
# ファイル保存
d.to_csv(filename,
sep='\t',
columns=[
"name",
"address",
"tel",
],
index=False)
"""
import pandas as pd
df = pd.read_csv("2018.tsv", sep='\t')
grouped_df = df.groupby("id")
with pd.ExcelWriter('data.xlsx', engine="openpyxl") as writer:
for id in grouped_df.groups:
d = grouped_df.get_group(id)
d.to_excel(writer, sheet_name=str(id), index=False, header=False)