Create a Pandas Timestamp and date_range Object
Let's find out how to use a pandas Timestamp and date_range.
We'll cover the following...
Try it yourself
Try executing the code below to see the result.
Press + to interact
Python 3.8
import pandas as pdstart = pd.Timestamp.fromtimestamp(0).strftime('%Y-%m-%d')times = pd.date_range(start=start, freq='M', periods=2)print(times)
Explanation
There are couple of puzzling things here:
Mis a month frequency.- The first date is January 31st and not January 1st.
Let’s start with M being a month frequency. You’ve probably used the infamous strftime or its cousin strptime to convert datetime to or from strings. In those cases, M stands for minute:
In [1]: t = ... Ask