pandas typing aliases#

Typing aliases#

The typing declarations in pandas/_typing.py are considered private, and used by pandas developers for type checking of the pandas code base. For users, it is highly recommended to use the pandas-stubs package that represents the officially supported type declarations for users of pandas. They are documented here for users who wish to use these declarations in their own python code that calls pandas or expects certain results.

Warning

Note that the definitions and use cases of these aliases are subject to change without notice in any major, minor, or patch release of pandas.

Each of these aliases listed in the table below can be found by importing them from pandas.api.typing.aliases.

Alias

Meaning

AggFuncType

Type of functions that can be passed to agg() methods

AlignJoin

Argument type for join in DataFrame.join()

AnyAll

Argument type for how in dropna()

AnyArrayLike

Used to represent ExtensionArray, numpy arrays, Index and Series

ArrayLike

Used to represent ExtensionArray, numpy arrays

AstypeArg

Argument type in astype()

Axes

AnyArrayLike plus sequences (not strings) and range

Axis

Argument type for axis in many methods

CSVEngine

Argument type for engine in DataFrame.read_csv()

ColspaceArgType

Argument type for colspace in DataFrame.to_html()

CompressionOptions

Argument type for compression in all I/O output methods except DataFrame.to_parquet()

CorrelationMethod

Argument type for correlation in corr()

DropKeep

Argument type for keep in drop_duplicates()

Dtype

Types as objects that can be used to specify dtypes

DtypeArg

Argument type for dtype in various methods

DtypeBackend

Argument type for dtype_backend in various methods

DtypeObj

Numpy dtypes and Extension dtypes

ExcelWriterIfSheetExists

Argument type for if_sheet_exists in ExcelWriter

ExcelWriterMergeCells

Argument type for merge_cells in to_excel()

FilePath

Type of paths for files for I/O methods

FillnaOptions

Argument type for method in various methods where NA values are filled

FloatFormatType

Argument type for float_format in to_string()

FormattersType

Argument type for formatters in to_string()

FromDictOrient

Argument type for orient in DataFrame.from_dict()

HTMLFlavors

Argument type for flavor in pandas.read_html()

IgnoreRaise

Argument type for errors in multiple methods

IndexLabel

Argument type for level in multiple methods

InterpolateOptions

Argument type for interpolate in interpolate()

JSONEngine

Argument type for engine in read_json()

JSONSerializable

Argument type for the return type of a callable for argument default_handler in to_json()

JoinHow

Argument type for how in pandas.merge_ordered() and for join in Series.align()

JoinValidate

Argument type for validate in DataFrame.join()

MergeHow

Argument type for how in merge()

MergeValidate

Argument type for validate in merge()

NaPosition

Argument type for na_position in sort_index() and sort_values()

NsmallestNlargestKeep

Argument type for keep in nlargest() and nsmallest()

OpenFileErrors

Argument type for errors in to_hdf() and to_csv()

Ordered

Return type for ordered` in CategoricalDtype and Categorical

ParquetCompressionOptions

Argument type for compression in DataFrame.to_parquet()

QuantileInterpolation

Argument type for interpolation in quantile()

ReadBuffer

Additional argument type corresponding to buffers for various file reading methods

ReadCsvBuffer

Additional argument type corresponding to buffers for pandas.read_csv()

ReadPickleBuffer

Additional argument type corresponding to buffers for pandas.read_pickle()

ReindexMethod

Argument type for reindex in reindex()

Scalar

Types that can be stored in Series with non-object dtype

SequenceNotStr

Used for arguments that require sequences, but not plain strings

SliceType

Argument types for start and end in Index.slice_locs()

SortKind

Argument type for kind in sort_index() and sort_values()

StorageOptions

Argument type for storage_options in various file output methods

Suffixes

Argument type for suffixes in merge(), compare() and merge_ordered()

TakeIndexer

Argument type for indexer and indices in take()

TimeAmbiguous

Argument type for ambiguous in time operations

TimeGrouperOrigin

Argument type for origin in resample() and TimeGrouper

TimeNonexistent

Argument type for nonexistent in time operations

TimeUnit

Time unit argument and return type for unit, arguments unit and date_unit

TimedeltaConvertibleTypes

Argument type for offset in resample(), halflife in ewm() and start and end in pandas.timedelta_range()

TimestampConvertibleTypes

Argument type for origin in resample() and pandas.to_datetime()

ToStataByteorder

Argument type for byteorder in DataFrame.to_stata()

ToTimestampHow

Argument type for how in to_timestamp() and convention in resample()

UpdateJoin

Argument type for join in DataFrame.update()

UsecolsArgType

Argument type for usecols in pandas.read_clipboard(), pandas.read_csv() and pandas.read_excel()

WindowingRankType

Argument type for method in rank`() in rolling and expanding window operations

WriteBuffer

Additional argument type corresponding to buffers for various file output methods

WriteExcelBuffer

Additional argument type corresponding to buffers for to_excel()

XMLParsers

Argument type for parser in DataFrame.to_xml() and pandas.read_xml()