| Action |
Code |
Details |
|
Object series from a generic list of values
|
pd.Series([1, None, 'a'])
|
|
|
Int series from a list of integers
|
pd.Series([1, '2', 3], dtype='int')
|
|
|
Nullable int series from a list of integers
|
pd.Series([1, None, 3], dtype = 'Int64')
|
Preserves None as |
|
Nullable int series filled with NA of length n
|
pd.Series([None] * 3, dtype='Int64')
|
|
|
Float series from list of numbers
|
pd.Series([1, None, 3], dtype='float')
|
None is converted to NaN! |
|
Nullable float series from a list of numbers
|
pd.Series([1, None, 3.5], dtype = 'Float64')
|
None, NA and NaN are all set to |
|
Nullable float series filled with NA of length n
|
pd.Series([None] * 3, dtype='Int64')
|
|
|
Categorical series from list of strings
|
pd.Categorical(['b', 'b', 'a'], categories=['a', 'b', 'c'])
|
|
|
Categorical series filled with NA of length n
|
pd.Categorical([None] * n, categories=['a', 'b', 'c'])
|
|
| Action |
Code |
Details |
|
Is series or subclass
|
|
|
|
Is series and not subclass
|
|
|
|
Empty
|
|
|
|
Not empty
|
|
|
|
Has length n
|
|
|
|
Is boolean series
|
pd.api.types.is_bool_dtype(x)
|
|
|
Is categorical series
|
isinstance(x.dtype, pd.CategoricalDtype)
|
|
|
Is ordered categorical series
|
isinstance(x.dtype, pd.CategoricalDtype) and x.ordered
|
|
|
Is numeric series
|
pd.api.types.is_numeric_dtype(x)
|
For example, int or float |
|
Is integer series
|
pd.api.types.is_integer_dtype(x)
|
For example, int or Int64 |
|
Is unsigned integer series
|
pd.api.types.is_unsigned_integer_dtype(x)
|
|
|
Is float series
|
pd.api.types.is_float_dtype(x)
|
For example, float or Float64 |
|
Is datetime64 series
|
pd.api.types.is_datetime64_dtype(x)
|
|
|
Is datetime64[ns] series
|
pd.api.types.is_datetime64_ns_dtype(x)
|
|
|
Is string series
|
pd.api.types.is_string_dtype(x)
|
|
|
Is object series
|
pd.api.types.is_object_dtype(x)
|
|
|
Is hashable series
|
pd.api.types.is_hashable(x)
|
|
|
No duplicate elements (all unique)
|
|
|
|
Any duplicate elements
|
|
|
|
Contains NA
|
|
|
|
Contains only NA
|
|
|
|
Contains no NA
|
|
|
|
Contains value v, ignoring NAs
|
|
WARNING: `v in x' tests the indices instead! |
|
Contains value v, ignoring NAs
|
|
|
|
Contains any of the values v1, v2, ignoring NAs
|
|
|
|
Does not contain value v
|
|
|
|
Are elements in increasing order
|
x.is_monotonic_increasing
|
|
|
Are elements in decreasing order
|
x.is_monotonic_decreasing
|
|
| Action |
Code |
Details |
|
Cast to boolean
|
|
|
|
Cast to integer
|
|
|
|
Cast to float
|
|
|
|
Cast to string
|
|
|
|
Cast to categorical (nominal)
|
|
|
|
Cast to categorical (nominal) with given categories
|
pd.Categorical(x, categories=['a', 'b', 'c'])
|
|
|
Cast to ordered categorical (ordinal)
|
pd.Categorical(x, ordered=True)
|
|
|
Cast categorical to integer codes
|
|
|
|
Cast ordered categorical to unordered categorical
|
|
|