DOC: to_datetime works real differently on DataFrames vs other datatypes
See original GitHub issueLocation of the documentation
- https://pandas.pydata.org/docs/reference/api/pandas.to_datetime.html
- https://pandas.pydata.org/docs/dev/reference/api/pandas.to_datetime.html?highlight=to_datetime
Documentation problem
The to_datetime
method does something wildly different on strings or Series vs DataFrames. This caught me by surprise and I think it would help if the documentation reflected this more clearly.
Suggested fix for documentation
Something along the lines of:
For most datatypes given to the to_datetime
method it creates datetime objects out of strings. If to_datetime
is given a dataframe it does something quite different: it combines columns that contain year, month and day information into datetime objects.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:5 (5 by maintainers)
Top Results From Across the Web
change multiple columns in pandas dataframe to datetime
I ran the code on my data frame (273771,), the to_datetime time was 1min13 sec vs the lookup was 59 sec. – smishra....
Read more >pandas.to_datetime — pandas 1.5.2 documentation
This function converts a scalar, array-like, Series or DataFrame /dict-like to a ... Many input types are supported, and lead to different output...
Read more >Pandas Convert Multiple Columns To DateTime Type
Let's see different ways to convert multiple columns from string, integer, and object to DataTime (date & time) type using pandas.to_datetime(),
Read more >Basic Time Series Manipulation with Pandas | by Laura Fedoruk
As someone who works with time series data on almost a daily basis, I have found the pandas Python package to be extremely...
Read more >DateTime in Pandas: A Simple Guide for Beginners (2022)
This tutorial will discuss different aspects of working with dates and times in pandas. After you finish this tutorial, you'll know the ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@mzeitlin11 Hello! I have created a Pull Request 😃
Thanks for reporting this @nielsbom - agreed further documentation would be helpful. There’s an outstanding pr to fix some issues (#42244), but don’t think it will completely handle what you mention.