Created
October 4, 2018 08:20
-
-
Save yassineAlouini/e67851bcc78036d4ea239a9b0d11829d to your computer and use it in GitHub Desktop.
Break a (large) CSV file into various ones per year.
This file contains hidden or 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 | |
INPUT_PATH = "your/input/path.csv" | |
OUPUT_PATH = "your/output/path_{}.csv" | |
df = pd.read_csv(INPUT_PATH, parse_dates=['tms_gmt']) | |
df['year'] = df.tms_gmt.dt.year | |
for year in df['year'].unique(): | |
df.loc[lambda df: df.year == year].to_csv(OUPUT_PATH.format(year), index=False) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment