This has been answered in the comments where it was noted that the following works:

Copydf.astype({'date': 'datetime64[ns]'})

In addition, you can set the dtype when reading in the data:

Copypd.read_csv('path/to/file.csv', parse_dates=['date'])
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.to_datetime.html
pandas.to_datetime — pandas 3.0.3 documentation
>>> df = pd.DataFrame({"year": [2015, 2016], "month": [2, 3], "day": [4, 5]}) >>> pd.to_datetime(df) 0 2015-02-04 1 2016-03-05 dtype: datetime64[us]
Top answer
1 of 2
36

This has been answered in the comments where it was noted that the following works:

Copydf.astype({'date': 'datetime64[ns]'})

In addition, you can set the dtype when reading in the data:

Copypd.read_csv('path/to/file.csv', parse_dates=['date'])
2 of 2
8

datetime

Since you can't pass datetime format to astype(), it's a little primitive and it's better to use pd.to_datetime() instead.

Copydf['date'] = pd.to_datetime(df['date'])

For example, if the dates in the data are of the format %d/%m/%Y such as 01/04/2020, astype() would incorrectly parse it as 2020-01-04 whereas with pd.to_datetime(), you can pass the correct format.

If you need to convert multiple columns into datetime64 (which is often the reason astype() is used), then you can apply pd.to_datetime().

Copydf = pd.DataFrame({'date1': ['01/04/2020'], 'date2': ['02/04/2020']})
df = df.apply(pd.to_datetime, format='%d/%m/%Y')

Even with read_csv, you have some control over the format, e.g.

Copydf = pd.read_csv('file.csv', parse_dates=['date'], dayfirst=True)

date

If you want to cast into date, then you can first cast to datetime64[ns] and then use dt.date to get a column of datetime.date objects:

Copydf['date'] = pd.to_datetime(df['date']).dt.date

The column dtype will become object though (on which you can still perform vectorized operations such as adding days, comparing dates etc.), so if you plan to work on it a lot in pandas, it's more performative to use datetime64 instead. For example, adding a day is extremely fast on datetime64 columns, not so much on date columns:

Copys_dt = pd.Series(pd.date_range('1700', None, 10000, 'D'))
s_d = s_dt.dt.date

%timeit x = s_dt + pd.Timedelta(days=1)
# 344 µs ± 17.3 µs per loop (mean ± std. dev. of 7 runs, 1,000 loops each)

%timeit y = s_d + pd.Timedelta(days=1)
# 56.1 ms ± 11.2 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)

With that being said, if you dump it into a database (such as sqlite), an object dtype column of datetime.date objects stored as a DATE type (whereas datetime64[ns] will be stored as TIMESTAMP).


Pandas datetime dtype is from numpy datetime64, so if you have pandas<2.0, you can use the following as well (since pandas 2.0, unitless datetime64 is not supported anymore). There's no date dtype (although you can perform vectorized operations on a column that holds datetime.date values).

Copydf = df.astype({'date': np.datetime64})

# or (on a little endian system)
df = df.astype({'date': '<M8'})
# (on a big endian system)
df = df.astype({'date': '>M8'})
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.DataFrame.astype.html
pandas.DataFrame.astype — pandas 3.0.3 documentation
>>> from pandas.api.types import CategoricalDtype >>> cat_dtype = CategoricalDtype(categories=[2, 1], ordered=True) >>> ser.astype(cat_dtype) 0 1 1 2 dtype: category Categories (2, int64): [2 < 1] ... >>> ser_date = pd.Series(pd.date_range("20200101", periods=3)) >>> ser_date 0 2020-01-01 1 2020-01-02 2 2020-01-03 dtype: datetime64[us]
🌐
Pandas
pandas.pydata.org › docs › user_guide › timeseries.html
Time series / date functionality — pandas 3.0.3 documentation
434 if format is not None and format != "mixed": --> 435 return _array_strptime_with_fallback(arg, name, utc, format, exact, errors) 437 result, tz_parsed = objects_to_datetime64( 438 arg, 439 dayfirst=dayfirst, (...) 443 allow_object=True, 444 ) 446 if tz_parsed is not None: 447 # We can take a shortcut since the datetime64 numpy array 448 # is in UTC File ~/work/pandas/pandas/pandas/core/tools/datetimes.py:470, in _array_strptime_with_fallback(arg, name, utc, fmt, exact, errors) 459 def _array_strptime_with_fallback( 460 arg, 461 name, (...) 465 errors: str, 466 ) -> Index: 467 """ 468 Call array_strptime, with fallback behavior depending on 'errors'.
🌐
GeeksforGeeks
geeksforgeeks.org › pandas › convert-the-column-type-from-string-to-datetime-format-in-pandas-dataframe
Convert Column Type from String to Datetime Format in Pandas Dataframe - GeeksforGeeks
Explanation: astype('datetime64[ns]') explicitly converts the “Date” column to datetime type. Change Data Type for one or more columns in Pandas Dataframe
Published   November 1, 2025
🌐
AskPython
askpython.com › home › converting string to numpy datetime64 in a dataframe
Converting String to Numpy Datetime64 in a Dataframe - AskPython
April 12, 2023 - The astype() is a simple function provided by the Pandas package. The function is used to convert the data into any other specified data type. The function takes a string argument that specifies the name of the desired data type.
🌐
Google Groups
groups.google.com › g › pydata › c › gQSi0ws_3Lo
using astype('datetime64[ns]')
My guess is that astype('datetime64[ns]') goes through NumPy's datetime64 machinery, which only parses ISO-8601 strings. Possibly astype() in pandas should be adjusted to use to_datetime() when appropriate.
🌐
GeeksforGeeks
geeksforgeeks.org › pandas › change-string-to-date-in-pandas-dataframe
Change String To Date In Pandas Dataframe - GeeksforGeeks
July 23, 2025 - Explanation: This code creates a DataFrame with date strings and numerical values, then uses astype('datetime64[ns]') to convert the 'Date' column into a datetime format, enabling efficient date-based operations.
Find elsewhere
🌐
GitHub
github.com › pandas-dev › pandas › issues › 11022
datetime64[ns] astype datetime64[s] · Issue #11022 · pandas-dev/pandas
September 7, 2015 - import pandas as pd import datetime as dt import numpy as np my_time = np.datetime64(dt.datetime.utcnow()) my_df = pd.DataFrame({"time": [my_time]*3}) my_df.time = my_df.time.astype("datetime64[s]") The error: TypeError Traceback (most recent call last) <ipython-input-150-0b63b4529623> in <module>() ----> 1 my_df.time = my_df.time.astype("datetime64[s]") /home/thomas/anaconda3/lib/python3.4/site-packages/pandas/core/generic.py in astype(self, dtype, copy, raise_on_error, **kwargs) 2409 2410 mgr = self._data.astype( -> 2411 dtype=dtype, copy=copy, raise_on_error=raise_on_error, **kwargs) 2412 r
Author   pandas-dev
🌐
GitHub
github.com › pandas-dev › pandas › issues › 52664
QST: How to convert dtype from datetime64[ns] to datetime · Issue #52664 · pandas-dev/pandas
April 14, 2023 - https://stackoverflow.com/questions/39207640/python-pandas-how-do-i-convert-from-datetime64ns-to-datetime · df[column].astype('datetime64') doesnt convert "datetime64[ns]" to datetime · Reactions are currently unavailable · No one assigned · Needs TriageIssue that has not been reviewed by a pandas team memberIssue that has not been reviewed by a pandas team memberUsage Question ·
Author   pandas-dev
🌐
GitHub
github.com › pandas-dev › pandas › issues › 25869
astype('datetime64[xx, UTC]') crashes if not nanoseconds · Issue #25869 · pandas-dev/pandas
March 25, 2019 - Code Sample, a copy-pastable example if possible import pandas as pd df = pd.DataFrame({'foo': ['2000-01-01T00:00:00.000Z+00:00']}) xf = df.copy() xf.foo = df.foo.astype('datetime64[ns, UTC]') # Works xf.foo = df.foo.astype('datetime64[u...
Author   pandas-dev
🌐
GitHub
github.com › pandas-dev › pandas › issues › 10746
astype attempts to convert datetime64[ms] as nanoseconds when missing value in data · Issue #10746 · pandas-dev/pandas
August 4, 2015 - When creating a DataFrame with a millisecond timestamp, created with dtype='datetime64[ms]', this works as expected when there are no missing values in the data: import pandas as pd df = pd.DataFrame([1036713600000], dtype='float64') print(df[0].astype('datetime64[ms]')) Output: 0 2002-11-08 Name: 0, dtype: datetime64[ns] Adding a missing value to the data causes the values to get parsed as nanoseconds rather than microseconds, which causes an exception: df = pd.DataFrame([1036713600000, None], dtype='float64') print(df[0].astype('datetime64[ms]')) Output: Traceback (most recent call last): Fi
Author   pandas-dev
🌐
GitHub
github.com › pandas-dev › pandas › issues › 49203
BUG: `astype('datetime64[us]')` has no effect on `datetime64[ns]` series · Issue #49203 · pandas-dev/pandas
October 20, 2022 - import pandas as pd data = [ { 'time': pd.Timestamp('2020-01-26 12:41:37.123456789') }, ] df = pd.DataFrame(data, columns=['time']) df['time'] = df['time'].astype('datetime64[us]') print(df['time'][0]) df.to_parquet("out.pq", index=True) In 1.5.0 and 1.5.1, it prints ·
Author   pandas-dev
🌐
GitHub
github.com › pandas-dev › pandas › issues › 47844
DOCS: series.astype return error when a datetime64 (unitless) series astype numpy.datetime64 · Issue #47844 · pandas-dev/pandas
July 25, 2022 - datetime64[s] return self._ndarray.astype(dtype) ... And raise an error. >>> import pandas as pd >>> import numpy >>> pd.Series(['1970-01-01', '1970-01-01', '1970-01-01'], dtype="datetime64[ns]").astype(numpy.datetime64, copy=False) 0 1970-01-01 1 1970-01-01 2 1970-01-01 dtype: datetime64[ns]
Author   pandas-dev
🌐
GitHub
github.com › pandas-dev › pandas-stubs › discussions › 958
astype with 'datetime64[us, UTC]' · pandas-dev/pandas-stubs · Discussion #958
Just revisiting old discussions to see if we can close some. I ran some experiments with the latest versions and it confirms that datetime64["us", UTC] will return a TypeError, while datetime64[us, UTC] is fully supported by the stubs.
Author   pandas-dev
🌐
GitHub
github.com › pandas-dev › pandas › issues › 17976
Performance difference between to_datetime & astype('datetime64[ns]') · Issue #17976 · pandas-dev/pandas
October 25, 2017 - %timeit pd.Series(np.arange(13...0000000)).astype('datetime64[ns]') 57.5 ms ± 987 µs per loop (mean ± std. dev. of 7 runs, 10 loops each) I am unable to find reason for this performance variance, any help will be great ... commit: None python: 3.5.2.final.0 python-bits: 64 OS: Linux OS-release: 4.4.0-79-generic machine: x86_64 processor: byteorder: little LC_ALL: en_US.UTF-8 LANG: C.UTF-8 LOCALE: en_US.UTF-8 · pandas: 0.20.2 pytest: ...
Author   pandas-dev
🌐
Practical Business Python
pbpython.com › pandas_dtypes.html
Overview of Pandas Data Types - Practical Business Python
Customer Number int64 Customer Name object 2016 float64 2017 float64 Percent Growth float64 Jan Units float64 Month int64 Day int64 Year int64 Active bool Start_Date datetime64[ns] The dataframe is ready for analysis! The basic concepts of using astype() and custom functions can be included very early in the data intake process.