Created
August 23, 2017 16:29
-
-
Save joseph-allen/ab08a425a484d79e5ab517d411816b78 to your computer and use it in GitHub Desktop.
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 | |
import sys | |
import itertools | |
def permute(df): | |
columns = [df[column] for column in list(df)] | |
uniq_columns = [columns[x].unique() for x in range(0, len(columns))] | |
return pd.DataFrame(list(itertools.product(*uniq_columns)), | |
columns=list(df)) | |
def main(): | |
print("Reading in Data from : " + sys.argv[1] + '\n') | |
df = pd.read_csv(sys.argv[1]) | |
print("Get Slices on : " + sys.argv[2] + '\n') | |
df = df[sys.argv[2].split()] | |
print 'Running permutation... \n' | |
df = permute(df) | |
print 'Printing Head :' | |
print(df.head()) | |
print '\n' | |
print('Printing csv to permutations.csv') | |
df.to_csv('permutations.csv') | |
print('done') | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment