Since version 0.15.0 this can now be easily done using .dt to access just the date component:

df['just_date'] = df['dates'].dt.date

The above returns datetime.date, so object dtype. If you want to keep the dtype as datetime64 then you can just normalize:

df['normalised_date'] = df['dates'].dt.normalize()

This sets the time component to midnight, i.e. 00:00:00, but the display shows just the date value.

  • pandas.Series.dt
Answer from EdChum on Stack Overflow
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.to_datetime.html
pandas.to_datetime — pandas 3.0.1 documentation
Convert argument to datetime. This function converts a scalar, array-like, Series or DataFrame/dict-like to a pandas datetime object.
🌐
Pandas
pandas.pydata.org › pandas-docs › version › 0.22 › generated › pandas.to_datetime.html
pandas.to_datetime — pandas 0.22.0 documentation
DatetimeIndex · TimedeltaIndex · PeriodIndex · Scalars · Window · GroupBy · Resampling · Style · General utility functions · Developer · Internals · Release Notes · Enter search terms or a module, class or function name. pandas.to_datetime(arg, errors='raise', dayfirst=False, yearfirst=False, utc=None, box=True, format=None, exact=True, unit=None, infer_datetime_format=False, origin='unix')[source]¶ ·
🌐
GeeksforGeeks
geeksforgeeks.org › python › how-to-convert-datetime-to-date-in-pandas
How to Convert Datetime to Date in Pandas ? - GeeksforGeeks
July 23, 2025 - After converting the 'DateTime' column to the date part using pd.to_datetime().dt.date, the updated DataFrame is displayed. The dtypes are shown before and after the conversion, highlighting the change in data types. ... # importing pandas module import pandas as pd # create pandas DataFrame with one column with five # datetime values through a dictionary df = pd.DataFrame({'DateTime': ['2021-01-15 20:02:11', '1989-05-24 20:34:11', '2020-01-18 14:43:24', '2021-01-15 20:02:10', '1999-04-04 20:34:11']}) print("---------Original data------------") print(df.dtypes) # convert datetime column to just date df['Date'] = pd.to_datetime(df['DateTime']).dt.date # display print("--------Only date---------") print(df.dtypes)
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.Series.dt.date.html
pandas.Series.dt.date — pandas 3.0.1 documentation
The day of the datetime. ... >>> s = pd.Series(["1/1/2020 10:00:00+00:00", "2/1/2020 11:00:00+00:00"]) >>> s = pd.to_datetime(s) >>> s 0 2020-01-01 10:00:00+00:00 1 2020-02-01 11:00:00+00:00 dtype: datetime64[us, UTC] >>> s.dt.date 0 2020-01-01 1 2020-02-01 dtype: object
🌐
Vultr Docs
docs.vultr.com › python › third-party › pandas › to_datetime
Python Pandas to_datetime() - Convert to DateTime | Vultr Docs
December 9, 2024 - The to_datetime() function in pandas is a powerful and flexible tool for converting strings, lists, or Series to DateTime objects, facilitating the manipulation and analysis of time-series data.
🌐
Programiz
programiz.com › python-programming › pandas › methods › to_datetime
Pandas to_datetime()
In the above example, we have used the pd.to_datetime() method to convert string dates into datetime objects. The resulting datetime objects are then printed, showing the converted dates. import pandas as pd # create a Series with some valid and some invalid date strings date_series = ...
Find elsewhere
🌐
PyImageSearch
pyimagesearch.com › home › blog › pandas to_datetime ( pd.to_datetime )
Pandas to_datetime ( pd.to_datetime ) - PyImageSearch
May 21, 2024 - Master the art of converting strings to datetime objects with Pandas' pd.to_datetime() function in this detailed tutorial. Learn essential techniques for handling and manipulating date and time data in Python, crucial for time series analysis.
🌐
Saturn Cloud
saturncloud.io › blog › how-to-change-datetime-format-in-pandas
How to Change Datetime Format in Pandas | Saturn Cloud Blog
October 19, 2023 - It is a combination of a date and a time, and can be represented in a variety of formats. Pandas provides a number of tools for working with datetime data, including the ability to parse datetime strings, create datetime objects from scratch, and perform various calculations and manipulations on datetime data.
🌐
Pandas
pandas.pydata.org › docs › user_guide › timeseries.html
Time series / date functionality — pandas 3.0.1 documentation
Changed in version 3.0.0: Previously, to_datetime() and DatetimeIndex would always parse strings to “ns” unit. During pandas 2.x, Timestamp could give any of “s”, “ms”, “us”, or “ns” depending on the specificity of the input string.
🌐
InfluxData
influxdata.com › home › pandas datetime: when and how to use it | influxdata
Pandas DateTime: When and How to Use It | InfluxData
January 16, 2024 - Once you have a DateTime object, ... a simple example to understand how Pandas DateTime works. Take a dataset that has a column containing date and time information....
🌐
Dataquest
dataquest.io › blog › datetime-in-pandas
DateTime in Pandas: An Uncomplicated Guide – Dataquest
May 12, 2025 - The pandas to_datetime() method converts a date/time value stored in a DataFrame column into a DateTime object. Having date/time values as DateTime objects makes manipulating them much easier.
🌐
Favtutor
favtutor.com › articles › pandas-datetime-to-date
Convert Datetime to Date Column in Pandas (with code)
January 4, 2024 - The following example will help you better understand it: import pandas as pd from datetime import datetime # Create a custom sample dataset data = {'Timestamp': [datetime(2023, 1, 15, 8, 30), datetime(2023, 1, 16, 12, 45), datetime(2023, 1, ...
🌐
GeeksforGeeks
geeksforgeeks.org › pandas › python-working-with-date-and-time-using-pandas
Python | Working with date and time using Pandas - GeeksforGeeks
July 11, 2025 - Let's try to understand with the examples discussed below. The date class in the DateTime module of Python deals with dates in the Gregorian calendar. It accepts three integer arguments: year, month, and day.
🌐
Reddit
reddit.com › r/learnpython › i need some help in understanding datetime within a pandas dataframe: data type and visualization
r/learnpython on Reddit: I need some help in understanding datetime within a pandas dataframe: data type and visualization
December 21, 2022 -

Howdy!

I'm having some difficult in working with datetime within a pandas dataframe, specifically a dataframe that's being imported from csv, excel and/or sql, which have dates already written on it.

I think that the issue is due to pandas somehow having an american default format of mm/dd/yyyy while I mostly use dd/mm/yyyy or yyyy-mm-dd (with time when needed), and working with datetime class or string class.

I've had cases when the excel had a dd/mm/yyyy date format (can't be sure if string or number) but pandas (vscode with jupyter) insisted on showing as yyyy-mm-dd as datetime column even though each value was apparently a string. It was weird because a similar column that should have been formatted the same had its data shown as some other format. I remember that I had applied a formula to transform it to datetime but it wouldn't reset back to the original format even after I restarted the kernal, as if the formula I applied was a permanent change or something.

So I have some questions:

  1. Can I have a datetime variable (that works with any datetime comparison/formulas) that is expressed/formatted as any format possible (like dd/mm/yyyy or yyyy-mm-dd)? This is important if I have to apply a filter to a dataframe, to define what format should I use and if I can use string or dataframe (df[df['date']=="21/12/2022'] or something like df[df['date']==datetime(2022,12,21)])

  2. I always have to export the data to a file (csv or xlsx) as an intermediate step. Should I export as a datetime or should I convert datetime to string? I'd rather have the data be exported in a way that is visually and systematically understood as a date (so a dd/mm/yyyy format but that excel/sql/other knows that it is a date)

I'm really lost and I've spent the whole day yesterday juggling variables and date formats just to simply compare the values between two different columns. I'm almost requesting an ELI5 because I'm that lost. Like I don't quite understand the difference or when to use datetime.strftime and datetime.strptime

Should I have some standard steps when working with dates within a dataframe, like always formating from string/datetime (default by pd.read) to datetime and then always converting to a specific format when exporting the dataframe (pd.to_)? What is the norm?

Can anyone give me some pointers to understand these things?

Cheers!

🌐
Spark By {Examples}
sparkbyexamples.com › home › pandas › pandas convert datetime to date column
Pandas Convert Datetime to Date Column - Spark By {Examples}
November 8, 2024 - To convert a datetime column to a date column in a Pandas DataFrame, you can use the dt accessor along with the date attribute. For example, the pd.to_datetime function is used to convert the ‘datetime_column’ to a datetime data type.
🌐
AskPython
askpython.com › home › how to change datetime format in pandas
How to Change Datetime Format in Pandas - AskPython
April 12, 2023 - This will convert the input datetime value to the desired format. Let’s first create a datetime value using the Pandas to_datetime function, the default format of this function is Year, then month and day values.
🌐
W3Schools
w3schools.com › python › pandas › pandas_cleaning_wrong_format.asp
Pandas - Cleaning Data of Wrong Format
Pandas HOME Pandas Intro Pandas Getting Started Pandas Series Pandas DataFrames Pandas Read CSV Pandas Read JSON Pandas Analyzing Data · Cleaning Data Cleaning Empty Cells Cleaning Wrong Format Cleaning Wrong Data Removing Duplicates ... Cells with data of wrong format can make it difficult, or even impossible, to analyze data. To fix it, you have two options: remove the rows, or convert all cells in the columns into the same format. In our Data Frame, we have two cells with the wrong format. Check out row 22 and 26, the 'Date' column should be a string that represents a date:
🌐
Programiz
programiz.com › python-programming › pandas › datetime
Pandas DateTime (With Examples)
We use the to_datetime() function to convert strings to the DateTime object. Let's look at an example. import pandas as pd # create a datetime string date_string = '2001-12-24 12:38' print("String:", date_string)