Skip to content

Instantly share code, notes, and snippets.

Created June 6, 2020 08:39
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save MarcinMoskala/01a8dc86c1ff6ce4b38a9eb06526f06c to your computer and use it in GitHub Desktop.
from pandas import read_csv
crimes_df = read_csv("CrimeData.csv")
crimes_df = crimes_df[crimes_df.year <= "2019"]
days_df = read_csv("DaysData.csv")
from datetime import datetime
def to_weekday(date):
return datetime.strptime(date, "%m/%d/%Y").strftime("%A")
crimes_df["weekday"] =
crimes_count_df = crimes_df \
.groupby(["weekday"]) \
.size() \
.to_frame("crimes") \
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment