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

type pandas.api.typing.aliases.AggFuncType#

Type of functions that can be passed to DataFrame's, Series', and DataFrameGroupBy's aggregate() methods

type pandas.api.typing.aliases.AlignJoin#

Argument type for join in DataFrame's and Series' align() methods

type pandas.api.typing.aliases.AnyAll#

Argument type for how in DataFrame's and Series' dropna() methods

type pandas.api.typing.aliases.AnyArrayLike#

Used to represent ExtensionArray, numpy arrays, Index and Series

type pandas.api.typing.aliases.ArrayLike#

Used to represent ExtensionArray, numpy arrays

type pandas.api.typing.aliases.AstypeArg#

Argument type in DataFrame's and Series' astype() methods

type pandas.api.typing.aliases.Axes#

AnyArrayLike plus sequences (not strings) and range

type pandas.api.typing.aliases.Axis#

Argument type for axis in many methods

type pandas.api.typing.aliases.CSVEngine#

Argument type for engine in pandas.read_csv()

type pandas.api.typing.aliases.ColspaceArgType#

Argument type for colspace in pandas.DataFrame.to_html()

type pandas.api.typing.aliases.CompressionOptions#

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

type pandas.api.typing.aliases.CorrelationMethod#

Argument type for correlation in DataFrame's and Series' corr() methods

type pandas.api.typing.aliases.DropKeep#

Argument type for keep in DataFrame's and Series' drop_duplicates() methods

type pandas.api.typing.aliases.Dtype#

Types as objects that can be used to specify dtypes

type pandas.api.typing.aliases.DtypeArg#

Argument type for dtype in various methods

type pandas.api.typing.aliases.DtypeBackend#

Argument type for dtype_backend in various methods

type pandas.api.typing.aliases.DtypeObj#

Numpy dtypes and Extension dtypes

type pandas.api.typing.aliases.ExcelWriterIfSheetExists#

Argument type for if_sheet_exists in ExcelWriter

type pandas.api.typing.aliases.ExcelWriterMergeCells#

Argument type for merge_cells in DataFrame's and Series' to_excel() methods

type pandas.api.typing.aliases.FilePath#

Type of paths for files for I/O methods

type pandas.api.typing.aliases.FillnaOptions#

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

type pandas.api.typing.aliases.FloatFormatType#

Argument type for float_format in DataFrame's and Series' to_string() methods

type pandas.api.typing.aliases.FormattersType#

Argument type for formatters in DataFrame's and Series' to_string() methods

type pandas.api.typing.aliases.FromDictOrient#

Argument type for orient in DataFrame.from_dict()

type pandas.api.typing.aliases.HTMLFlavors#

Argument type for flavor in pandas.read_html()

type pandas.api.typing.aliases.IgnoreRaise#

Argument type for errors in multiple methods

type pandas.api.typing.aliases.IndexLabel#

Argument type for level in multiple methods

type pandas.api.typing.aliases.InterpolateOptions#

Argument type for interpolate in DataFrame's and Series' interpolate() methods

type pandas.api.typing.aliases.IntervalClosedType#

Argument type for closed in Interval, IntervalIndex, and inclusive in various methods

type pandas.api.typing.aliases.IntervalLeftRight#

Restriction for closed to be left or right in Interval, IntervalIndex, and inclusive in various methods

type pandas.api.typing.aliases.JSONEngine#

Argument type for engine in pandas.read_json()

type pandas.api.typing.aliases.JSONSerializable#

Argument type for the return type of a callable for argument default_handler in DataFrame's and Series' to_json() methods

type pandas.api.typing.aliases.JoinHow#

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

type pandas.api.typing.aliases.JoinValidate#

Argument type for validate in DataFrame.join()

type pandas.api.typing.aliases.ListLike#

Argument type for arguments that can be either a single value or a list of values in various methods

type pandas.api.typing.aliases.MergeHow#

Argument type for how in pandas.merge()

type pandas.api.typing.aliases.MergeValidate#

Argument type for validate in pandas.merge()

type pandas.api.typing.aliases.NaPosition#

Argument type for na_position in DataFrame's and Series' sort_values() methods

type pandas.api.typing.aliases.NsmallestNlargestKeep#

Argument type for keep in DataFrame's and Series' nlargest(), DataFrame's and Series' nsmallest(), and SeriesGroupBy's nlargest() methods

type pandas.api.typing.aliases.OpenFileErrors#

Argument type for errors in DataFrame's, Series' to_hdf() methods, and DataFrame's and Series' to_csv() methods

type pandas.api.typing.aliases.Ordered#

Return type for ordered in pandas.CategoricalDtype and pandas.Categorical

type pandas.api.typing.aliases.ParquetCompressionOptions#

Argument type for compression in DataFrame.to_parquet()

type pandas.api.typing.aliases.QuantileInterpolation#

Argument type for interpolation in DataFrame's and Series' quantile() methods

type pandas.api.typing.aliases.ReadBuffer#

Additional argument type corresponding to buffers for various file reading methods

type pandas.api.typing.aliases.ReadCsvBuffer#

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

type pandas.api.typing.aliases.ReadPickleBuffer#

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

type pandas.api.typing.aliases.ReindexMethod#

Argument type for reindex in DataFrame's and Series' reindex() methods

type pandas.api.typing.aliases.Scalar#

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

type pandas.api.typing.aliases.ScalarIndexer#

Argument type used for scalar indexing operations, such as the key argument in __getitem__() methods

type pandas.api.typing.aliases.SequenceIndexer#

Argument type used for sequence indexing operations, such as the key argument in __getitem__() methods

type pandas.api.typing.aliases.SequenceNotStr#

Used for arguments that require sequences, but not plain strings

type pandas.api.typing.aliases.SliceType#

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

type pandas.api.typing.aliases.SortKind#

Argument type for kind in DataFrame's and Series' sort_values() methods

type pandas.api.typing.aliases.StorageOptions#

Argument type for storage_options in various file output methods

type pandas.api.typing.aliases.Suffixes#

Argument type for suffixes in pandas.merge(), pandas.merge_ordered(), and DataFrame's and Series' compare() methods

type pandas.api.typing.aliases.TakeIndexer#

Argument type for indexer and indices in DataFrame's and Series' take() methods

type pandas.api.typing.aliases.TimeAmbiguous#

Argument type for ambiguous in time operations

type pandas.api.typing.aliases.TimeGrouperOrigin#

Argument type for origin in DataFrame's, Series' resample() methods and for Grouper

type pandas.api.typing.aliases.TimeNonexistent#

Argument type for nonexistent in time operations

type pandas.api.typing.aliases.TimeUnit#

Time unit argument and return type for pandas.Timedelta.unit, arguments unit and date_unit

type pandas.api.typing.aliases.TimedeltaConvertibleTypes#

Argument type for offset in various methods, such as DataFrame's and Series' resample(), halflife in DataFrame's, DataFrameGroupBy's, and Series' ewm(), and start and end in pandas.timedelta_range()

type pandas.api.typing.aliases.TimestampConvertibleTypes#

Argument type for origin in DataFrame's and Series' resample(), and in pandas.to_datetime()

type pandas.api.typing.aliases.ToStataByteorder#

Argument type for byteorder in DataFrame.to_stata()

type pandas.api.typing.aliases.ToTimestampHow#

Argument type for how in DataFrame's and Series' to_timestamp() methods, and convention in DataFrame's and Series' resample() methods

type pandas.api.typing.aliases.UpdateJoin#

Argument type for join in DataFrame.update()

type pandas.api.typing.aliases.UsecolsArgType#

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

type pandas.api.typing.aliases.WindowingRankType#

Argument type for method in Rolling's and Expanding's rank() methods, applicable in rolling and expanding window operations

type pandas.api.typing.aliases.WriteBuffer#

Additional argument type corresponding to buffers for various file output methods

type pandas.api.typing.aliases.WriteExcelBuffer#

Additional argument type corresponding to buffers for DataFrame's, Series' and Styler's to_excel() methods

type pandas.api.typing.aliases.XMLParsers#

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