Now we need to sort the rows in the order we want them. Test_values = Ĭombine the dates and the data into a dataframeĭf = pd.DataFrame(index=test_dates, data=test_values)Īdd a columns showing what day of the week each day isĭf = df.apply(lambda x: x.weekday()) # get the weekday index, between 0 and 6ĭf = df.apply(lambda x: calendar.day_name) Periods=None, freq='D', tz=None, normalize=False, name=None, closed=None)ĭtype='datetime64', length=227, freq='D')Ĭreate a list of random numbers for each date Here's a gist of an example in a Jupyter notebook, or I explain the steps below. We obviously need to be able to determine what weekday a particular date is and, if we want to visualise this information, we're probably going to want to sort the days by the order they are in a week e.g 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', rather than alphabetically. This is reasonably easy to do in python, with a few caveats. advertising or website traffic etc, its useful to aggregate the date by the day of the week.įor example, over the winter holiday period, how many sales did we make on a 'Sunday'?
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |