Skip to content

Instantly share code, notes, and snippets.

@khuyentran1401
Last active January 5, 2022 23:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save khuyentran1401/ffbf655e3de7a2e72a53fbdb4512ecf2 to your computer and use it in GitHub Desktop.
Save khuyentran1401/ffbf655e3de7a2e72a53fbdb4512ecf2 to your computer and use it in GitHub Desktop.
# Group by salary range
bins = [0, 25_000, 50_000, 75_000, 100_000, 125_000, 150_000, 300_000]
normal_salary["Salary Range"] = pd.cut(
normal_salary.dropna(subset=["ConvertedSalary"])["ConvertedSalary"], bins=bins
)
salary_groupby = normal_salary.groupby("Salary Range").agg({"Respondent": "count"})
# Create a bar plot
salary_groupby.plot(kind="bar")
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment