Skip to content

Instantly share code, notes, and snippets.

@DalyaG
Created May 9, 2020 20:36
Show Gist options
  • Save DalyaG/866d74ea396433754313e28f8d6a7315 to your computer and use it in GitHub Desktop.
Save DalyaG/866d74ea396433754313e28f8d6a7315 to your computer and use it in GitHub Desktop.
Group DataFrame by color
df['has_black'] = df['color'].str.contains("black")
df_grouped_color = (df.groupby(['weekday_num', 'weekday_name'])
['has_black']
.value_counts()
.unstack()
.reset_index(level=0, drop=True))
df_grouped_color
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment