Python | Pandas DatetimeIndex.to_pydatetime() Last Updated : 29 Dec, 2018 Summarize Comments Improve Suggest changes Share Like Article Like 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.to_pydatetime() function return DatetimeIndex as object ndarray of datetime.datetime objects. The function does not take any input value. Syntax: DatetimeIndex.to_pydatetime() Parameters : None Return : ndarray Example #1: Use DatetimeIndex.to_pydatetime() function to convert the DatetimeIndex as object ndarray of datetime.datetime objects. Python3 # importing pandas as pd import pandas as pd # Create the DatetimeIndex # Here 'S' represents secondly frequency didx = pd.DatetimeIndex(start ='2018-11-15 09:45:10', freq ='S', periods = 5) # Print the DatetimeIndex print(didx) Output : Now we want to convert the DatetimeIndex to datetime.datetime objects. Python3 # convert to datetime.datetime objects. didx.to_pydatetime() Output : As we can see in the output, the function has converted the DatetimeIndex object to python datetime.datetime object. Example #2: Use DatetimeIndex.to_pydatetime() function to convert the DatetimeIndex as object ndarray of datetime.datetime objects. Python3 # importing pandas as pd import pandas as pd # Create the DatetimeIndex # Here 'M' represents monthly frequency didx = pd.DatetimeIndex(start ='2015-03-02', freq ='M', periods = 5) # Print the DatetimeIndex print(didx) Output : Now we want to convert the DatetimeIndex to datetime.datetime objects. Python3 # convert to datetime.datetime objects. didx.to_pydatetime() Output : As we can see in the output, the function has converted the DatetimeIndex object to python datetime.datetime object. Comment More infoAdvertise with us Next Article Python | Pandas DatetimeIndex.to_period() S Shubham__Ranjan Follow Improve Article Tags : Technical Scripter Python Python-pandas Python pandas-datetimeIndex Practice Tags : python Similar Reads Python | Pandas DatetimeIndex.to_period() 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.to_period() function is used to cast the given DatetimeIndex to P 2 min read Python | Pandas DatetimeIndex.to_perioddelta() 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.to_perioddelta() function calculate TimedeltaIndex of difference 2 min read Python | Pandas DatetimeIndex.time 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.time attribute outputs an Index object containing the time values 2 min read Python | Pandas DatetimeIndex.to_frame() 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.to_frame() function create a DataFrame with a column containing t 2 min read Python | Pandas DatetimeIndex.round() 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.round() function localize tz-naive DatetimeIndex to tz-aware Date 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 ye 2 min read Like