Pandas Convert Date (Datetime) To String Format Last Updated : 12 Jun, 2025 Comments Improve Suggest changes Like Article Like Report We are given a column containing datetime values in a pandas DataFrame and our task is to convert these datetime objects into string format. This conversion is useful for visualizing data, exporting it to external applications, or performing string operations. For example, if we have this input:a = { 'dt': pd.to_datetime(['2024-01-01', '2024-01-02', '2024-01-03']), 'x': [101, 201, 301], 'y': [909, 1809, 2709]}Then the output after conversion to strings might look like: dt x y0 01-01-2024 101 9091 02-01-2024 201 18092 03-01-2024 301 2709Using astype(str)The astype(str) method converts the datetime column directly into strings. This approach is simple but does not allow formatting customization. Python import pandas as pd a = { 'dt': pd.to_datetime(['2024-01-01', '2024-01-02', '2024-01-03']), 'x': [101, 201, 301], 'y': [909, 1809, 2709] } df = pd.DataFrame(a) print(type(df['dt'][0])) df['dt'] = df['dt'].astype(str) print(type(df['dt'][0])) Output<class 'pandas._libs.tslibs.timestamps.Timestamp'> <type 'str'> Explanation:astype(str) changes the entire column dt from datetime to string type.type() checks the datatype before and after conversion.Using strftime()The strftime() method formats each datetime value into a string based on the format you specify. Python import pandas as pd a = { 'dt': pd.to_datetime(['2024-01-01', '2024-01-02', '2024-01-03']), 'x': [101, 201, 301], 'y': [909, 1809, 2709] } df = pd.DataFrame(a) df['dt'] = df['dt'].dt.strftime('%d-%m-%Y') print(df) df.info() Output: dt x y0 01-01-2024 101 9091 02-01-2024 201 18092 03-01-2024 301 2709<class 'pandas.core.frame.DataFrame'>RangeIndex: 3 entries, 0 to 2Data columns (total 3 columns): # Column Non-Null Count Dtype --- ------ -------------- ----- 0 dt 3 non-null object 1 x 3 non-null int64 2 y 3 non-null int64 Explanation:strftime('%d-%m-%Y') converts each date to a custom string format.The dt accessor is used to apply string formatting on datetime columns.Using apply() with lambdaYou can convert datetime to string using the apply() function with a lambda expression. This offers flexibility to apply custom logic during conversion. Python import pandas as pd a = { 'dt': pd.to_datetime(['2024-01-01', '2024-01-02', '2024-01-03']), 'x': [101, 201, 301], 'y': [909, 1809, 2709] } df = pd.DataFrame(a) df['dt'] = df['dt'].apply(lambda d: d.strftime('%B %d, %Y')) print(df) Output dt x y 0 January 01, 2024 101 909 1 January 02, 2024 201 1809 2 January 03, 2024 301 2709 Explanation:.apply(lambda d: d.strftime(...)) allows full customization of the date format.You can use any valid format inside strftime — e.g., full month name with %B. Comment More infoAdvertise with us Next Article Pandas Convert Date (Datetime) To String Format S sairampadala811 Follow Improve Article Tags : Geeks Premier League Pandas Geeks Premier League 2023 Similar Reads How to Convert Datetime to Date in Pandas ? DateTime is a collection of dates and times in the format of "yyyy-mm-dd HH:MM:SS" where yyyy-mm-dd is referred to as the date and HH:MM:SS is referred to as Time. In this article, we are going to discuss converting DateTime to date in pandas. For that, we will extract the only date from DateTime us 4 min read How to Convert String to Date or Datetime in Polars When working with data, particularly in CSV files or databases, it's common to find dates stored as strings. If we're using Polars, a fast and efficient DataFrame library written in Rust (with Python bindings), we'll often need to convert these strings into actual date or datetime objects for easier 5 min read Convert column type from string to datetime format in Pandas dataframe To perform time-series operations, dates should be in the correct format. Let's learn how to convert a Pandas DataFrame column of strings to datetime format. Pandas Convert Column To DateTime using pd.to_datetime()pd.to_datetime() function in Pandas is the most effective way to handle this conversio 4 min read How to Convert Integer to Datetime in Pandas DataFrame? Let's discuss how to convert an Integer to Datetime in it. Now to convert Integers to Datetime in Pandas DataFrame. Syntax of  pd.to_datetimedf['DataFrame Column'] = pd.to_datetime(df['DataFrame Column'], format=specify your format)Create the DataFrame to Convert Integer to Datetime in Pandas Check 2 min read Convert Date To Datetime In Python When you're programming, dealing with dates and times is important, and Python provides tools to manage them well. This article is about changing dates into date times in Python. We'll explore methods that can help you switch between these two types of data. Whether you're building a website or work 3 min read How to convert datetime to date in Python In this article, we are going to see how to convert DateTime to date in Python. For this, we will use the strptime() method and Pandas module. This method is used to create a DateTime object from a string. Then we will extract the date from the DateTime object using the date() function and dt.date f 3 min read Change String To Date In Pandas Dataframe Working with date and time data in a Pandas DataFrame is common, but sometimes dates are stored as strings and need to be converted into proper date formats for analysis and visualization. In this article, we will explore multiple methods to convert string data to date format in a Pandas DataFrame.U 5 min read Python - Convert excel serial date to datetime This article will discuss the conversion of an excel serial date to DateTime in Python. The Excel "serial date" format is actually the number of days since 1900-01-00 i.e., January 1st, 1900. For example, the excel serial date number 43831 represents January 1st, 2020, and after converting 43831 to 3 min read Create Python Datetime from string In this article, we are going to see how to create a python DateTime object from a given string. For this, we will use the datetime.strptime() method. The strptime() method returns a DateTime object corresponding to date_string, parsed according to the format string given by the user. Syntax: datet 4 min read How to Change Pandas Dataframe Datetime to Time The DatetimeIndex contains datetime64[ns] data type, which represents timestamps with nanosecond precision. In many cases, we may just want to extract the time component from a Pandas Datetime column or index. Let's discuss easy ways to convert the Datetime to Time data while preserving all the time 2 min read Like