Pandas Series property: dt.is_year_start
Series.dt.is_year_start property
The is_year_start property is used to check whether a given date is the first day of a year or not.
Syntax:
Series.dt.is_year_start
Returns: Series or DatetimeIndex
The same type as the original data with boolean values.
Series will have the same name and index.
DatetimeIndex will have the same name.
Example:
Python-Pandas Code:
import numpy as np
import pandas as pd
dates = pd.Series(pd.date_range("2019-12-30", periods=3))
dates
Output:
0 2019-12-30 1 2019-12-31 2 2020-01-01 dtype: datetime64[ns]
Python-Pandas Code:
import numpy as np
import pandas as pd
dates = pd.Series(pd.date_range("2019-12-30", periods=3))
dates.dt.is_year_start
Output:
0 False 1 False 2 True dtype: bool
Python-Pandas Code:
import numpy as np
import pandas as pd
idx = pd.date_range("2019-12-30", periods=3)
idx
Output:
DatetimeIndex(['2019-12-30', '2019-12-31', '2020-01-01'], dtype='datetime64[ns]', freq='D')
Python-Pandas Code:
import numpy as np
import pandas as pd
idx = pd.date_range("2019-12-30", periods=3)
idx.is_year_start
Output:
array([False, False, True])
Previous: Series.dt.is_quarter_end property
Next: Series.dt.is_year_end property
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://w3resource.com/pandas/series/series-dt-is_year_start.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics