Last active
September 26, 2018 13:03
-
-
Save WillKoehrsen/62d67730e5a99cb71b22a3f6b9c49366 to your computer and use it in GitHub Desktop.
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 | |
# Convert customer id to partition number | |
members['partition'] = members['msno'].apply(id_to_hash) | |
# Iteration through grouped partitions | |
for partition, grouped in members.groupby('partition'): | |
# Open file for appending | |
with open(file_dir + f'p{partition}/members.csv', 'a') as f: | |
# Write a new line and then the contents of the dataframe | |
f.write('\n') | |
grouped.to_csv(f, header = False, index = False) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment