![]() |
VOOZH | about |
Pandas dt.to_pydatetime() method returns the data as an array of native Python DateTime objects. Timezone information is retained if present.
Output :
Syntax: Series.dt.to_pydatetime()
Parameter: None
Returns: numpy ndarray
To convert a Pandas Series DateTime object into a Python DateTime object we use the Series.dt.to_pydatetime method.
Let us understand it better with an example:
Use the Series.dt.to_pydatetime() function to return the given series object as an array of native Python DateTime objects.
Output :
Now we will use the dt.to_pydatetime() function to return the data as an array of native Python DateTime objects.
Output :
👁 python datetime objects returned
As we can see in the output, the Series.dt.to_pydatetime() function has successfully returned the underlying data of the given series object as an array of native Python DateTime data.