Difference between revisions of "Python dates"
Jump to navigation
Jump to search
(Created page with "Python dates are a notorious pain in the ass. Here's a short field guide. ===Object types=== When using <code> pd.to_datetime </code> with a text date (e.g., '2022-05-19'), t...") |
|||
| Line 2: | Line 2: | ||
===Object types=== | ===Object types=== | ||
When using <code> pd.to_datetime </code> with a text date (e.g., '2022-05-19'), the result is a *timestamp* object. | When using <code> pd.to_datetime </code> with a text date (e.g., '2022-05-19'), the result is a *timestamp* object. | ||
| − | <syntaxhighlight | + | <syntaxhighlight lang=Python> |
df['Date'].iloc[0] | df['Date'].iloc[0] | ||
Timestamp('2022-05-19 00:00:00') | Timestamp('2022-05-19 00:00:00') | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Revision as of 19:54, 18 November 2023
Python dates are a notorious pain in the ass. Here's a short field guide.
Object types
When using pd.to_datetime with a text date (e.g., '2022-05-19'), the result is a *timestamp* object.
df['Date'].iloc[0]
Timestamp('2022-05-19 00:00:00')