Skip to content

Tag: date

Sort a pandas dataframe series by month name

I have a Series object that has: Problem statement: I want to make it appear by month and compute the mean price for each month and present it with a sorted manner by month. Desired Output: I thought of making a list and passing it in a sort function: but the sort_values doesn’t support that for series. One big problem

Python module to change system date and time

How can I change System Date, Time, Timezone in Python? Is there any module available for this? I don’t want to execute any system commands I want one common solution, which should work on both Unix and Windows. Answer I don’t have a windows machine so I didn’t test it on windows… But you get the idea.

How do I get the day of week given a date?

I want to find out the following: given a date (datetime object), what is the corresponding day of the week? For instance, Sunday is the first day, Monday: second day.. and so on And then if the input is something like today’s date. Example The output is maybe 6 (since it’s Friday) Answer Use weekday(): From the documentation: Return the

Checking date against date range in Python

I have a date variable: 2011-01-15 and I would like to get a boolean back if said date is within 3 days from TODAY. Im not quite sure how to construct this in Python. Im only dealing with date, not datetime. My working example is a “grace period”. A user logs into my site and […]