pandas borrows its dtypes from numpy. For demonstration of this see the following:

import pandas as pd

df = pd.DataFrame({'A': [1,'C',2.]})
df['A'].dtype

>>> dtype('O')

type(df['A'].dtype)

>>> numpy.dtype

You can find the list of valid numpy.dtypes in the documentation:

'?' boolean

'b' (signed) byte

'B' unsigned byte

'i' (signed) integer

'u' unsigned integer

'f' floating-point

'c' complex-floating point

'm' timedelta

'M' datetime

'O' (Python) objects

'S', 'a' zero-terminated bytes (not recommended)

'U' Unicode string

'V' raw data (void)

pandas should support these types. Using the astype method of a pandas.Series object with any of the above options as the input argument will result in pandas trying to convert the Series to that type (or at the very least falling back to object type); 'u' is the only one that I see pandas not understanding at all:

df['A'].astype('u')

>>> TypeError: data type "u" not understood

This is a numpy error that results because the 'u' needs to be followed by a number specifying the number of bytes per item in (which needs to be valid):

import numpy as np

np.dtype('u')

>>> TypeError: data type "u" not understood

np.dtype('u1')

>>> dtype('uint8')

np.dtype('u2')

>>> dtype('uint16')

np.dtype('u4')

>>> dtype('uint32')

np.dtype('u8')

>>> dtype('uint64')

# testing another invalid argument
np.dtype('u3')

>>> TypeError: data type "u3" not understood

To summarise, the astype methods of pandas objects will try and do something sensible with any argument that is valid for numpy.dtype. Note that numpy.dtype('f') is the same as numpy.dtype('float32') and numpy.dtype('f8') is the same as numpy.dtype('float64') etc. Same goes for passing the arguments to pandas astype methods.

To locate the respective data type classes in NumPy, the Pandas docs recommends this:

def subdtypes(dtype):
    subs = dtype.__subclasses__()
    if not subs:
        return dtype
    return [dtype, [subdtypes(dt) for dt in subs]]

subdtypes(np.generic)

Output:

[numpy.generic,
 [[numpy.number,
   [[numpy.integer,
     [[numpy.signedinteger,
       [numpy.int8,
        numpy.int16,
        numpy.int32,
        numpy.int64,
        numpy.int64,
        numpy.timedelta64]],
      [numpy.unsignedinteger,
       [numpy.uint8,
        numpy.uint16,
        numpy.uint32,
        numpy.uint64,
        numpy.uint64]]]],
    [numpy.inexact,
     [[numpy.floating,
       [numpy.float16, numpy.float32, numpy.float64, numpy.float128]],
      [numpy.complexfloating,
       [numpy.complex64, numpy.complex128, numpy.complex256]]]]]],
  [numpy.flexible,
   [[numpy.character, [numpy.bytes_, numpy.str_]],
    [numpy.void, [numpy.record]]]],
  numpy.bool_,
  numpy.datetime64,
  numpy.object_]]

Pandas accepts these classes as valid types. For example, dtype={'A': np.float}.

NumPy docs contain more details and a chart:

Answer from lcameron05 on Stack Overflow
๐ŸŒ
Pandas
pandas.pydata.org โ€บ docs โ€บ reference โ€บ arrays.html
pandas arrays, scalars, and data types โ€” pandas 3.0.1 documentation
For most data types, pandas uses NumPy arrays as the concrete objects contained with a Index, Series, or DataFrame.
๐ŸŒ
Pandas
pandas.pydata.org โ€บ docs โ€บ reference โ€บ api โ€บ pandas.DataFrame.dtypes.html
pandas.DataFrame.dtypes โ€” pandas 3.0.1 documentation
This returns a Series with the data type of each column. The resultโ€™s index is the original DataFrameโ€™s columns. Columns with mixed types are stored with the object dtype. See the User Guide for more. Returns: pandas.Series ยท The data type of each column.
๐ŸŒ
Dsc80
notes.dsc80.com โ€บ content โ€บ 02 โ€บ data-types.html
Pandas Data Types and Performance Considerations โ€” Data Science in Practice
In Pandas, a Data Type is a classification that specifies the type of the values of a column. Understanding data types in Pandas leads to cleaner, better optimized (in both space and time), less error-prone code.
Top answer
1 of 3
71

pandas borrows its dtypes from numpy. For demonstration of this see the following:

import pandas as pd

df = pd.DataFrame({'A': [1,'C',2.]})
df['A'].dtype

>>> dtype('O')

type(df['A'].dtype)

>>> numpy.dtype

You can find the list of valid numpy.dtypes in the documentation:

'?' boolean

'b' (signed) byte

'B' unsigned byte

'i' (signed) integer

'u' unsigned integer

'f' floating-point

'c' complex-floating point

'm' timedelta

'M' datetime

'O' (Python) objects

'S', 'a' zero-terminated bytes (not recommended)

'U' Unicode string

'V' raw data (void)

pandas should support these types. Using the astype method of a pandas.Series object with any of the above options as the input argument will result in pandas trying to convert the Series to that type (or at the very least falling back to object type); 'u' is the only one that I see pandas not understanding at all:

df['A'].astype('u')

>>> TypeError: data type "u" not understood

This is a numpy error that results because the 'u' needs to be followed by a number specifying the number of bytes per item in (which needs to be valid):

import numpy as np

np.dtype('u')

>>> TypeError: data type "u" not understood

np.dtype('u1')

>>> dtype('uint8')

np.dtype('u2')

>>> dtype('uint16')

np.dtype('u4')

>>> dtype('uint32')

np.dtype('u8')

>>> dtype('uint64')

# testing another invalid argument
np.dtype('u3')

>>> TypeError: data type "u3" not understood

To summarise, the astype methods of pandas objects will try and do something sensible with any argument that is valid for numpy.dtype. Note that numpy.dtype('f') is the same as numpy.dtype('float32') and numpy.dtype('f8') is the same as numpy.dtype('float64') etc. Same goes for passing the arguments to pandas astype methods.

To locate the respective data type classes in NumPy, the Pandas docs recommends this:

def subdtypes(dtype):
    subs = dtype.__subclasses__()
    if not subs:
        return dtype
    return [dtype, [subdtypes(dt) for dt in subs]]

subdtypes(np.generic)

Output:

[numpy.generic,
 [[numpy.number,
   [[numpy.integer,
     [[numpy.signedinteger,
       [numpy.int8,
        numpy.int16,
        numpy.int32,
        numpy.int64,
        numpy.int64,
        numpy.timedelta64]],
      [numpy.unsignedinteger,
       [numpy.uint8,
        numpy.uint16,
        numpy.uint32,
        numpy.uint64,
        numpy.uint64]]]],
    [numpy.inexact,
     [[numpy.floating,
       [numpy.float16, numpy.float32, numpy.float64, numpy.float128]],
      [numpy.complexfloating,
       [numpy.complex64, numpy.complex128, numpy.complex256]]]]]],
  [numpy.flexible,
   [[numpy.character, [numpy.bytes_, numpy.str_]],
    [numpy.void, [numpy.record]]]],
  numpy.bool_,
  numpy.datetime64,
  numpy.object_]]

Pandas accepts these classes as valid types. For example, dtype={'A': np.float}.

NumPy docs contain more details and a chart:

2 of 3
59

EDIT Feb 2020 following pandas 1.0.0 release

Pandas mostly uses NumPy arrays and dtypes for each Series (a dataframe is a collection of Series, each which can have its own dtype). NumPy's documentation further explains dtype, data types, and data type objects. In addition, the answer provided by @lcameron05 provides an excellent description of the numpy dtypes. Furthermore, the pandas docs on dtypes have a lot of additional information.

The main types stored in pandas objects are float, int, bool, datetime64[ns], timedelta[ns], and object. In addition these dtypes have item sizes, e.g. int64 and int32.

By default integer types are int64 and float types are float64, REGARDLESS of platform (32-bit or 64-bit). The following will all result in int64 dtypes.

Numpy, however will choose platform-dependent types when creating arrays. The following WILL result in int32 on 32-bit platform. One of the major changes to version 1.0.0 of pandas is the introduction of pd.NA to represent scalar missing values (rather than the previous values of np.nan, pd.NaT or None, depending on usage).

Pandas extends NumPy's type system and also allows users to write their on extension types. The following lists all of pandas extension types.

1) Time zone handling

Kind of data: tz-aware datetime (note that NumPy does not support timezone-aware datetimes).

Data type: DatetimeTZDtype

Scalar: Timestamp

Array: arrays.DatetimeArray

String Aliases: 'datetime64[ns, ]'

2) Categorical data

Kind of data: Categorical

Data type: CategoricalDtype

Scalar: (none)

Array: Categorical

String Aliases: 'category'

3) Time span representation

Kind of data: period (time spans)

Data type: PeriodDtype

Scalar: Period

Array: arrays.PeriodArray

String Aliases: 'period[]', 'Period[]'

4) Sparse data structures

Kind of data: sparse

Data type: SparseDtype

Scalar: (none)

Array: arrays.SparseArray

String Aliases: 'Sparse', 'Sparse[int]', 'Sparse[float]'

5) IntervalIndex

Kind of data: intervals

Data type: IntervalDtype

Scalar: Interval

Array: arrays.IntervalArray

String Aliases: 'interval', 'Interval', 'Interval[<numpy_dtype>]', 'Interval[datetime64[ns, ]]', 'Interval[timedelta64[]]'

6) Nullable integer data type

Kind of data: nullable integer

Data type: Int64Dtype, ...

Scalar: (none)

Array: arrays.IntegerArray

String Aliases: 'Int8', 'Int16', 'Int32', 'Int64', 'UInt8', 'UInt16', 'UInt32', 'UInt64'

7) Working with text data

Kind of data: Strings

Data type: StringDtype

Scalar: str

Array: arrays.StringArray

String Aliases: 'string'

8) Boolean data with missing values

Kind of data: Boolean (with NA)

Data type: BooleanDtype

Scalar: bool

Array: arrays.BooleanArray

String Aliases: 'boolean'

๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ pandas โ€บ pandas-dataframe-dtypes
Pandas DataFrame dtypes Property | Find Data Type of Columns - GeeksforGeeks
July 11, 2025 - Use the DataFrame dtypes attribute to find out the data type (dtype) of each column in the given DataFrame. ... # importing pandas as pd import pandas as pd # Creating the DataFrame df = pd.DataFrame({& quot A&quot: [12, 4, 5, None, 1], & quot B&quot : [7, 2, 54, 3, None], & quot C&quot : [20, 16, 11, 3, 8], & quot D&quot : [14, 3, None, 2, 6]}) # Create the index index_ = ['Row_1', 'Row_2', 'Row_3', 'Row_4', 'Row_5'] # Set the index df.index = index_ # Print the DataFrame print(df)
๐ŸŒ
Pandas
pandas.pydata.org โ€บ docs โ€บ user_guide โ€บ dsintro.html
Intro to data structures โ€” pandas 3.0.1 documentation - PyData |
This is often a NumPy dtype. However, pandas and 3rd-party libraries extend NumPyโ€™s type system in a few places, in which case the dtype would be an ExtensionDtype. Some examples within pandas are Categorical data and Nullable integer data type.
Find elsewhere
๐ŸŒ
Hyperskill
hyperskill.org โ€บ learn โ€บ step โ€บ 33215
Data types in pandas
Hyperskill is an educational platform for learning programming and software development through project-based courses, that helps you secure a job in tech. Master Python, Java, Kotlin, and more with real-world coding challenges.
๐ŸŒ
Data Carpentry
datacarpentry.github.io โ€บ python-ecology-lesson โ€บ 04-data-types-and-format.html
Data Analysis and Visualization in Python for Ecologists: Data Types and Formats
June 5, 2023 - Describe how information is stored in a pandas DataFrame. Define the two main types of data in pandas: text and numerics.
๐ŸŒ
Pandas
pandas.pydata.org โ€บ docs โ€บ reference โ€บ api โ€บ pandas.DataFrame.astype.html
pandas.DataFrame.astype โ€” pandas 3.0.1 documentation
Cast a numpy array to a specified type. ... Changed in version 2.0.0: Using astype to convert from timezone-naive dtype to timezone-aware dtype will raise an exception. Use Series.dt.tz_localize() instead. ... >>> d = {"col1": [1, 2], "col2": [3, 4]} >>> df = pd.DataFrame(data=d) >>> df.dtypes col1 int64 col2 int64 dtype: object ... >>> ser = pd.Series([1, 2], dtype="int32") >>> ser 0 1 1 2 dtype: int32 >>> ser.astype("int64") 0 1 1 2 dtype: int64 ... >>> 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]
๐ŸŒ
APXML
apxml.com โ€บ courses โ€บ intro-eda-course โ€บ chapter-2-data-loading-inspection-cleaning โ€บ understanding-data-types
Pandas Data Types (dtypes) Explained
After loading your data and getting a first glimpse using methods like .head(), .tail(), and .shape(), the next logical step is to understand the kind of data stored in each column. In Pandas, this information is captured by the data type, or dtype, associated with each Series (column) in your ...
๐ŸŒ
Studymachinelearning
studymachinelearning.com โ€บ pandas-data-types
Pandas : Data Types โ€“ Study Machine Learning
In [3]: df['C'] = df['C'].astype('int') # Change Data type of column C to integer df['C'].dtypes Out[3]: dtype('int64') In [4]: df['A'] = df['A'].astype('str') # Change Data type of column A to string df.dtypes Out[4]: A object B object C int64 dtype: object ยท panda.to_numeric() method used to change the data type to numeric type.
๐ŸŒ
BMC Software
bmc.com โ€บ blogs โ€บ pandas-data-types
Pandas Data Types โ€“ BMC Software | Blogs
December 16, 2020 - Regular Python does not have many data types. It only has string, float, binary, and complex numbers. There is no longer or short. There are no 32- or 64-bit numbers. Luckily, for most situations, this doesnโ€™t matter.
๐ŸŒ
Saturn Cloud
saturncloud.io โ€บ blog โ€บ how-to-set-dtypes-by-column-in-pandas-dataframe
How to Set dtypes by Column in Pandas DataFrame | Saturn Cloud Blog
November 13, 2023 - In pandas, data types are referred to as dtypes. Each column in a DataFrame can have a different dtype, depending on the type of data it contains.
Top answer
1 of 1
3

df.dtypes is the canonical way to obtain data type identifiers. You can print for each dtype the associated underlying numpy dtype code with <dtype>.str. You can also get the kind (integer, float, ...) with <dtype>.kind:

import pandas as pd
from datetime import datetime

headers = ["string", "integer", "float", "boolean", "timestamp"]
data = [["a", 1, 1.0, True, datetime.now()]]

df = pd.DataFrame(data, columns=headers)

dts = df.dtypes
for index, value in dts.items():
    print("column %s dtype[class: %s; name: %s; code: %s; kind: %s]" % (index, type(value), value.name, value.str, value.kind))

yields:

column string dtype[class: <class 'numpy.dtype'>; name: object; code: |O; kind: O]
column integer dtype[class: <class 'numpy.dtype'>; name: int64; code: <i8; kind: i]
column float dtype[class: <class 'numpy.dtype'>; name: float64; code: <f8; kind: f]
column boolean dtype[class: <class 'numpy.dtype'>; name: bool; code: |b1; kind: b]
column timestamp dtype[class: <class 'numpy.dtype'>; name: datetime64[ns]; code: <M8[ns]; kind: M]

The issue is that some datatypes are defined specifically in pandas as you noted, but they are backed by numpy datatypes (they have numpy datatype codes). For example, numpy defines the datetime64[ns] that you can see above, but pandas defines a timezone-localized dtype on top of it. You can see it :

# localize with timezone
df['timestamp'] = pd.DatetimeIndex(df['timestamp']).tz_localize(tz='UTC')

# look at the dtype of timestamp: now a pandas dtype
index, value = 'timestamp', df.dtypes.timestamp
print("column %s dtype[class: %s; name: %s; code: %s; kind: %s]" % (index, type(value), value.name, value.str, value.kind))

yields

column timestamp dtype[class: <class 'pandas.core.dtypes.dtypes.DatetimeTZDtype'>; name: datetime64[ns, UTC]; code: |M8[ns]; kind: M]    

Now the dtype class is a custom pandas class (DatetimeTZDtype), while the underlying dtype code is a numpy one. The same would go if you use string datatypes, that are not in numpy by default.

So to sum-up, to reach your original goal, you should first look at the type(<dtype>) and if it is not a custom pandas one, then to look at the numpy <dtype>.kind (It is preferrable to <dtype>.str as numpy allows you to define many kind of integers (big/little endian, nb of bits, etc.)).

Finally as you found out, Dataframe.convert_dtypes() is a converter, and it has parameters to select which auto-conversion feature to turn on/off.

๐ŸŒ
Medium
medium.com โ€บ dunder-data โ€บ data-types-and-missing-values-aa0003e51b27
Pandas Data Types and Missing Values โ€” Master Data Analysis with Python Chapter 3 | by Ted Petrou | Dunder Data | Medium
June 27, 2022 - pandas stores its data such that each column is exactly one data type. A large number of data types are available for pandas DataFrame columns. This chapter focuses only on the most common data types and provides a brief summary of each one. For extensive coverage of each and every data type, see part 05.
๐ŸŒ
Pandas
pandas.pydata.org โ€บ docs โ€บ user_guide โ€บ text.html
Working with text data โ€” pandas 3.0.1 documentation
Changed in version 3.0: The default when pandas infers the dtype of a collection of strings is to use dtype='str'. This will use np.nan as itโ€™s NA value and be backed by a PyArrow string array when PyArrow is installed, or backed by NumPy object array when PyArrow is not installed.