w3resource

Pandas Series property: dt.is_month_start

Series.dt.is_month_start property

The is_month_start property is used to check whether a given date is the first day of the month or not.

Syntax:

Series.dt.is_month_start
Pandas Series: dt.is_month_start property

Returns: Series or array
For Series, returns a Series with boolean values.
For DatetimeIndex, returns a boolean array.

Example:

Python-Pandas Code:

import numpy as np
import pandas as pd
s = pd.Series(pd.date_range("2019-02-27", periods=3))
s

Output:

0   2019-02-27
1   2019-02-28
2   2019-03-01
dtype: datetime64[ns]

Python-Pandas Code:

import numpy as np
import pandas as pd
s = pd.Series(pd.date_range("2019-02-27", periods=3))
s.dt.is_month_start

Output:

0    False
1    False
2     True
dtype: bool

Python-Pandas Code:

import numpy as np
import pandas as pd
s = pd.Series(pd.date_range("2019-02-27", periods=3))
s.dt.is_month_end

Output:

0    False
1     True
2    False
dtype: bool

Python-Pandas Code:

import numpy as np
import pandas as pd
idx = pd.date_range("2019-02-27", periods=3)
idx.is_month_start

Output:

array([False, False,  True])
Pandas Series: dt.is_month_start property

Python-Pandas Code:

import numpy as np
import pandas as pd
idx = pd.date_range("2019-02-27", periods=3)
idx.is_month_end

Output:

array([False,  True, False])

Previous: Series.dt.weekday property
Next: Series.dt.is_month_end property



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://www.w3resource.com/pandas/series/series-dt-is_month_start.php