Skip to content

Instantly share code, notes, and snippets.

@SandroLuck
Created December 12, 2020 00:13
Show Gist options
  • Save SandroLuck/98bc0f43e012d1a0067ea91f84055d43 to your computer and use it in GitHub Desktop.
Save SandroLuck/98bc0f43e012d1a0067ea91f84055d43 to your computer and use it in GitHub Desktop.
import random
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
get_point = lambda: {'Type': random.choice(['Liker', 'Subscriber', 'Like & Sub']),
'Age': random.randint(20, 40),
'Gender': random.choice(['M', 'W', 'T']),
'MemberSince': random.randint(2010, 2020)}
df = pd.DataFrame([get_point() for i in range(1000)])
print(df)
sns.boxplot(x='Type', y='MemberSince', hue='Gender', data=df)
plt.show()
sns.heatmap(df[['Gender', 'Type']].pivot_table(index='Type', columns='Gender',
aggfunc=len, fill_value=0))
print(df[['Gender', 'Type']].pivot_table(index='Type', columns='Gender',
aggfunc=len, fill_value=0))
plt.show()
sns.scatterplot(data=df[:100], x='Age', y='MemberSince', hue='Type')
plt.show()
sns.countplot(data=df, y='MemberSince', hue='Type')
plt.show()
sns.lineplot(data=df[:100], x='Age', y='MemberSince', hue='Type')
plt.show()
sns.displot(data=df[:100], x='Age')
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment