Open In App

Python | Pandas DatetimeIndex.is_year_start

Last Updated : 24 Dec, 2018
Improve
Improve
Like Article
Like
Save
Share
Report

Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier.

Pandas DatetimeIndex.is_year_start attribute is an indicator for whether the date is the first day of the year. If the date is the first day of the year it returns True else it return False.

Syntax: DatetimeIndex.is_year_start

Return: numpy array containing logical values.

Example #1: Use DatetimeIndex.is_year_start attribute to check if the dates present in the DatetimeIndex object is the first day of the year.




# importing pandas as pd
import pandas as pd
  
# Create the DatetimeIndex
didx = pd.DatetimeIndex(['2014-01-01', '2014-04-30', '2017-03-31', '2000-12-02'])
  
# Print the DatetimeIndex
print(didx)


Output :

Now we want to find if the dates contained in the given DatetimeIndex object is the first day of the year.




# find if the days are the first day of the year.
didx.is_year_start


Output :

As we can see in the output, the function has returned a numpy array containing logical values for each entry of the DatetimeIndex object. True values indicate the corresponding date was the first day of the year and False value indicate the corresponding date was not the first day of the year.
 
Example #2: Use DatetimeIndex.is_year_start attribute to check if the dates present in the DatetimeIndex object is the first day of the year.




# importing pandas as pd
import pandas as pd
  
# Create the DatetimeIndex
didx = pd.date_range('2011-12-30', periods = 5)
  
# Print the DatetimeIndex
print(didx)


Output :

Now we want to find if the dates contained in the given DatetimeIndex object is the first day of the year.




# find if the days are the first day of the year.
didx.is_year_start


Output :

As we can see in the output, the function has returned a numpy array containing logical values for each entry of the DatetimeIndex object. True values indicate the corresponding date was the first day of the year and False value indicate the corresponding date was not the first day of the year.



Similar Reads

Python | Pandas Timestamp.is_year_start
Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier. Pandas Timestamp.is_year_start attribute return a boolean value. It return True if the date in the given Timestamp object is the start o
2 min read
Python | Pandas Series.dt.is_year_start
Series.dt can be used to access the values of the series as datetimelike and return several properties. Pandas Series.dt.is_year_start attribute return a boolean value Indicating whether the date is the first day of a year. Syntax: Series.dt.is_year_start Parameter : None Returns : numpy array Example #1: Use Series.dt.is_year_start attribute to ch
2 min read
Python | Pandas DatetimeIndex.inferred_freq
Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier. Pandas DatetimeIndex.inferred_freq attribute tries to return a string representing a frequency guess, generated by infer_freq. For those
2 min read
Python | Pandas DatetimeIndex.is_quarter_start
Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier. Pandas DatetimeIndex.is_quarter_start attribute is an indicator for whether the date is the first day of a quarter. If the date is the f
2 min read
Python | Pandas DatetimeIndex.is_quarter_end
Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier. Pandas DatetimeIndex.is_quarter_end attribute is an indicator for whether the date is the last day of a quarter. If the date is the last
2 min read
Python | Pandas DatetimeIndex.is_year_end
Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier. Pandas DatetimeIndex.is_year_end attribute is an indicator for whether the date is the last day of the year. If the date is the last day
2 min read
Python | Pandas DatetimeIndex.is_leap_year
Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier. Pandas DatetimeIndex.is_leap_year attribute return a boolean indicator if the date belongs to a leap year. A leap year is a year, which
2 min read
Python | Pandas DatetimeIndex.year
Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier. Pandas DatetimeIndex.year attribute outputs an Index object containing the value of years present in the Datetime object. Syntax: Dateti
2 min read
Python | Pandas DatetimeIndex.month
Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier. Pandas DatetimeIndex.month attribute outputs an Index object containing numeric values corresponding to each entry in the DatetimeIndex
2 min read
Python | Pandas DatetimeIndex.day
Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier. Pandas DatetimeIndex.day attribute outputs an Index object containing the days in each of the entries of the DatetimeIndex object. Synta
2 min read
Practice Tags :