Skip to content

Instantly share code, notes, and snippets.

@ravishchawla
Created June 6, 2019 16:51
Show Gist options
  • Save ravishchawla/b2fcda921d85e07d4c306a525885c059 to your computer and use it in GitHub Desktop.
Save ravishchawla/b2fcda921d85e07d4c306a525885c059 to your computer and use it in GitHub Desktop.
Starbucks post: Create transactions only dataframes
transcript_profile = pd.merge(transcript, profile, left_on='person', right_on='id')
# keep only records of actual transactions, and keep integer columns
transaction_data_only = transcript_profile[transcript_profile.event_transaction == 1];
transaction_data_only = transaction_data_only.select_dtypes(exclude=['object']);
# separate into male and female dataframes
transaction_data_f = transaction_data_only[transaction_data_only.gender_F == 1]
transaction_data_m = transaction_data_only[transaction_data_only.gender_M == 1]
transaction_data_only.head()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment