pandas.Series   classpandas.Series(data=None, index=None, dtype=None, name=None, copy=False, fastpath=False)[source]

One-dimensional ndarray with axis labels (including time series). Labels need not be unique but must be a hashable type. The object supports both integer- and label-based indexing and provides a host of methods for performing operations involving the index. Statistical methods from ndarray have been overridden to automatically exclude missing data (currently represented as NaN). Operations between Series (+, -, /, *, **) align values based on their associated index values– they need not be the same length. The result index will be the sorted union of the two indexes.  Parameters

data:array-like, Iterable, dict, or scalar value

Contains data stored in Series. If data is a dict, argument order is maintained.
index:array-like or Index (1d)

Values must be hashable and have the same length as data. Non-unique index values are allowed. Will default to RangeIndex (0, 1, 2, …, n) if not provided. If data is dict-like and index is None, then the keys in the data are used as the index. If the index is not None, the resulting Series is reindexed with the index values.
dtype:str, numpy.dtype, or ExtensionDtype, optional

Data type for the output Series. If not specified, this will be inferred from data. See the user guide for more usages.
name:str, optional

The name to give to the Series.
copy:bool, default False

Copy input data. Only affects Series or 1d ndarray input. See examples.     Examples Constructing Series from a dictionary with an Index specified
>>> d = {'a': 1, 'b': 2, 'c': 3}
>>> ser = pd.Series(data=d, index=['a', 'b', 'c'])
>>> ser
a   1
b   2
c   3
dtype: int64
  The keys of the dictionary match with the Index values, hence the Index values have no effect.
>>> d = {'a': 1, 'b': 2, 'c': 3}
>>> ser = pd.Series(data=d, index=['x', 'y', 'z'])
>>> ser
x   NaN
y   NaN
z   NaN
dtype: float64
  Note that the Index is first build with the keys from the dictionary. After this the Series is reindexed with the given Index values, hence we get all NaN as a result. Constructing Series from a list with copy=False.
>>> r = [1, 2]
>>> ser = pd.Series(r, copy=False)
>>> ser.iloc[0] = 999
>>> r
[1, 2]
>>> ser
0    999
1      2
dtype: int64
  Due to input data type the Series has a copy of the original data even though copy=False, so the data is unchanged. Constructing Series from a 1d ndarray with copy=False.
>>> r = np.array([1, 2])
>>> ser = pd.Series(r, copy=False)
>>> ser.iloc[0] = 999
>>> r
array([999,   2])
>>> ser
0    999
1      2
dtype: int64
  Due to input data type the Series has a view on the original data, so the data is changed as well. Attributes
T Return the transpose, which is by definition self.
array The ExtensionArray of the data backing this Series or Index.
at Access a single value for a row/column label pair.
attrs Dictionary of global attributes of this dataset.
axes Return a list of the row axis labels.
dtype Return the dtype object of the underlying data.
dtypes Return the dtype object of the underlying data.
flags Get the properties associated with this pandas object.
hasnans Return True if there are any NaNs.
iat Access a single value for a row/column pair by integer position.
iloc Purely integer-location based indexing for selection by position.
index The index (axis labels) of the Series.
is_monotonic Return boolean if values in the object are monotonic_increasing.
is_monotonic_decreasing Return boolean if values in the object are monotonic_decreasing.
is_monotonic_increasing Alias for is_monotonic.
is_unique Return boolean if values in the object are unique.
loc Access a group of rows and columns by label(s) or a boolean array.
name Return the name of the Series.
nbytes Return the number of bytes in the underlying data.
ndim Number of dimensions of the underlying data, by definition 1.
shape Return a tuple of the shape of the underlying data.
size Return the number of elements in the underlying data.
values Return Series as ndarray or ndarray-like depending on the dtype.
empty     Methods
abs() Return a Series/DataFrame with absolute numeric value of each element.
add(other[, level, fill_value, axis]) Return Addition of series and other, element-wise (binary operator add).
add_prefix(prefix) Prefix labels with string prefix.
add_suffix(suffix) Suffix labels with string suffix.
agg([func, axis]) Aggregate using one or more operations over the specified axis.
aggregate([func, axis]) Aggregate using one or more operations over the specified axis.
align(other[, join, axis, level, copy, ...]) Align two objects on their axes with the specified join method.
all([axis, bool_only, skipna, level]) Return whether all elements are True, potentially over an axis.
any([axis, bool_only, skipna, level]) Return whether any element is True, potentially over an axis.
append(to_append[, ignore_index, ...]) Concatenate two or more Series.
apply(func[, convert_dtype, args]) Invoke function on values of Series.
argmax([axis, skipna]) Return int position of the largest value in the Series.
argmin([axis, skipna]) Return int position of the smallest value in the Series.
argsort([axis, kind, order]) Return the integer indices that would sort the Series values.
asfreq(freq[, method, how, normalize, ...]) Convert time series to specified frequency.
asof(where[, subset]) Return the last row(s) without any NaNs before where.
astype(dtype[, copy, errors]) Cast a pandas object to a specified dtype dtype.
at_time(time[, asof, axis]) Select values at particular time of day (e.g., 9:30AM).
autocorr([lag]) Compute the lag-N autocorrelation.
backfill([axis, inplace, limit, downcast]) Synonym for DataFrame.fillna() with method='bfill'.
between(left, right[, inclusive]) Return boolean Series equivalent to left <= series <= right.
between_time(start_time, end_time[, ...]) Select values between particular times of the day (e.g., 9:00-9:30 AM).
bfill([axis, inplace, limit, downcast]) Synonym for DataFrame.fillna() with method='bfill'.
bool() Return the bool of a single element Series or DataFrame.
cat alias of pandas.core.arrays.categorical.CategoricalAccessor
clip([lower, upper, axis, inplace]) Trim values at input threshold(s).
combine(other, func[, fill_value]) Combine the Series with a Series or scalar according to func.
combine_first(other) Update null elements with value in the same location in 'other'.
compare(other[, align_axis, keep_shape, ...]) Compare to another Series and show the differences.
convert_dtypes([infer_objects, ...]) Convert columns to best possible dtypes using dtypes supporting pd.NA.
copy([deep]) Make a copy of this object's indices and data.
corr(other[, method, min_periods]) Compute correlation with other Series, excluding missing values.
count([level]) Return number of non-NA/null observations in the Series.
cov(other[, min_periods, ddof]) Compute covariance with Series, excluding missing values.
cummax([axis, skipna]) Return cumulative maximum over a DataFrame or Series axis.
cummin([axis, skipna]) Return cumulative minimum over a DataFrame or Series axis.
cumprod([axis, skipna]) Return cumulative product over a DataFrame or Series axis.
cumsum([axis, skipna]) Return cumulative sum over a DataFrame or Series axis.
describe([percentiles, include, exclude, ...]) Generate descriptive statistics.
diff([periods]) First discrete difference of element.
div(other[, level, fill_value, axis]) Return Floating division of series and other, element-wise (binary operator truediv).
divide(other[, level, fill_value, axis]) Return Floating division of series and other, element-wise (binary operator truediv).
divmod(other[, level, fill_value, axis]) Return Integer division and modulo of series and other, element-wise (binary operator divmod).
dot(other) Compute the dot product between the Series and the columns of other.
drop([labels, axis, index, columns, level, ...]) Return Series with specified index labels removed.
drop_duplicates([keep, inplace]) Return Series with duplicate values removed.
droplevel(level[, axis]) Return Series/DataFrame with requested index / column level(s) removed.
dropna([axis, inplace, how]) Return a new Series with missing values removed.
dt alias of pandas.core.indexes.accessors.CombinedDatetimelikeProperties
duplicated([keep]) Indicate duplicate Series values.
eq(other[, level, fill_value, axis]) Return Equal to of series and other, element-wise (binary operator eq).
equals(other) Test whether two objects contain the same elements.
ewm([com, span, halflife, alpha, ...]) Provide exponentially weighted (EW) calculations.
expanding([min_periods, center, axis, method]) Provide expanding window calculations.
explode([ignore_index]) Transform each element of a list-like to a row.
factorize([sort, na_sentinel]) Encode the object as an enumerated type or categorical variable.
ffill([axis, inplace, limit, downcast]) Synonym for DataFrame.fillna() with method='ffill'.
fillna([value, method, axis, inplace, ...]) Fill NA/NaN values using the specified method.
filter([items, like, regex, axis]) Subset the dataframe rows or columns according to the specified index labels.
first(offset) Select initial periods of time series data based on a date offset.
first_valid_index() Return index for first non-NA value or None, if no NA value is found.
floordiv(other[, level, fill_value, axis]) Return Integer division of series and other, element-wise (binary operator floordiv).
ge(other[, level, fill_value, axis]) Return Greater than or equal to of series and other, element-wise (binary operator ge).
get(key[, default]) Get item from object for given key (ex: DataFrame column).
groupby([by, axis, level, as_index, sort, ...]) Group Series using a mapper or by a Series of columns.
gt(other[, level, fill_value, axis]) Return Greater than of series and other, element-wise (binary operator gt).
head([n]) Return the first n rows.
hist([by, ax, grid, xlabelsize, xrot, ...]) Draw histogram of the input series using matplotlib.
idxmax([axis, skipna]) Return the row label of the maximum value.
idxmin([axis, skipna]) Return the row label of the minimum value.
infer_objects() Attempt to infer better dtypes for object columns.
info([verbose, buf, max_cols, memory_usage, ...]) Print a concise summary of a Series.
interpolate([method, axis, limit, inplace, ...]) Fill NaN values using an interpolation method.
isin(values) Whether elements in Series are contained in values.
isna() Detect missing values.
isnull() Series.isnull is an alias for Series.isna.
item() Return the first element of the underlying data as a Python scalar.
items() Lazily iterate over (index, value) tuples.
iteritems() Lazily iterate over (index, value) tuples.
keys() Return alias for index.
kurt([axis, skipna, level, numeric_only]) Return unbiased kurtosis over requested axis.
kurtosis([axis, skipna, level, numeric_only]) Return unbiased kurtosis over requested axis.
last(offset) Select final periods of time series data based on a date offset.
last_valid_index() Return index for last non-NA value or None, if no NA value is found.
le(other[, level, fill_value, axis]) Return Less than or equal to of series and other, element-wise (binary operator le).
lt(other[, level, fill_value, axis]) Return Less than of series and other, element-wise (binary operator lt).
mad([axis, skipna, level]) Return the mean absolute deviation of the values over the requested axis.
map(arg[, na_action]) Map values of Series according to an input mapping or function.
mask(cond[, other, inplace, axis, level, ...]) Replace values where the condition is True.
max([axis, skipna, level, numeric_only]) Return the maximum of the values over the requested axis.
mean([axis, skipna, level, numeric_only]) Return the mean of the values over the requested axis.
median([axis, skipna, level, numeric_only]) Return the median of the values over the requested axis.
memory_usage([index, deep]) Return the memory usage of the Series.
min([axis, skipna, level, numeric_only]) Return the minimum of the values over the requested axis.
mod(other[, level, fill_value, axis]) Return Modulo of series and other, element-wise (binary operator mod).
mode([dropna]) Return the mode(s) of the Series.
mul(other[, level, fill_value, axis]) Return Multiplication of series and other, element-wise (binary operator mul).
multiply(other[, level, fill_value, axis]) Return Multiplication of series and other, element-wise (binary operator mul).
ne(other[, level, fill_value, axis]) Return Not equal to of series and other, element-wise (binary operator ne).
nlargest([n, keep]) Return the largest n elements.
notna() Detect existing (non-missing) values.
notnull() Series.notnull is an alias for Series.notna.
nsmallest([n, keep]) Return the smallest n elements.
nunique([dropna]) Return number of unique elements in the object.
pad([axis, inplace, limit, downcast]) Synonym for DataFrame.fillna() with method='ffill'.
pct_change([periods, fill_method, limit, freq]) Percentage change between the current and a prior element.
pipe(func, *args, **kwargs) Apply chainable functions that expect Series or DataFrames.
plot alias of pandas.plotting._core.PlotAccessor
pop(item) Return item and drops from series.
pow(other[, level, fill_value, axis]) Return Exponential power of series and other, element-wise (binary operator pow).
prod([axis, skipna, level, numeric_only, ...]) Return the product of the values over the requested axis.
product([axis, skipna, level, numeric_only, ...]) Return the product of the values over the requested axis.
quantile([q, interpolation]) Return value at the given quantile.
radd(other[, level, fill_value, axis]) Return Addition of series and other, element-wise (binary operator radd).
rank([axis, method, numeric_only, ...]) Compute numerical data ranks (1 through n) along axis.
ravel([order]) Return the flattened underlying data as an ndarray.
rdiv(other[, level, fill_value, axis]) Return Floating division of series and other, element-wise (binary operator rtruediv).
rdivmod(other[, level, fill_value, axis]) Return Integer division and modulo of series and other, element-wise (binary operator rdivmod).
reindex(*args, **kwargs) Conform Series to new index with optional filling logic.
reindex_like(other[, method, copy, limit, ...]) Return an object with matching indices as other object.
rename([index, axis, copy, inplace, level, ...]) Alter Series index labels or name.
rename_axis([mapper, index, columns, axis, ...]) Set the name of the axis for the index or columns.
reorder_levels(order) Rearrange index levels using input order.
repeat(repeats[, axis]) Repeat elements of a Series.
replace([to_replace, value, inplace, limit, ...]) Replace values given in to_replace with value.
resample(rule[, axis, closed, label, ...]) Resample time-series data.
reset_index([level, drop, name, inplace]) Generate a new DataFrame or Series with the index reset.
rfloordiv(other[, level, fill_value, axis]) Return Integer division of series and other, element-wise (binary operator rfloordiv).
rmod(other[, level, fill_value, axis]) Return Modulo of series and other, element-wise (binary operator rmod).
rmul(other[, level, fill_value, axis]) Return Multiplication of series and other, element-wise (binary operator rmul).
rolling(window[, min_periods, center, ...]) Provide rolling window calculations.
round([decimals]) Round each value in a Series to the given number of decimals.
rpow(other[, level, fill_value, axis]) Return Exponential power of series and other, element-wise (binary operator rpow).
rsub(other[, level, fill_value, axis]) Return Subtraction of series and other, element-wise (binary operator rsub).
rtruediv(other[, level, fill_value, axis]) Return Floating division of series and other, element-wise (binary operator rtruediv).
sample([n, frac, replace, weights, ...]) Return a random sample of items from an axis of object.
searchsorted(value[, side, sorter]) Find indices where elements should be inserted to maintain order.
sem([axis, skipna, level, ddof, numeric_only]) Return unbiased standard error of the mean over requested axis.
set_axis(labels[, axis, inplace]) Assign desired index to given axis.
set_flags(*[, copy, allows_duplicate_labels]) Return a new object with updated flags.
shift([periods, freq, axis, fill_value]) Shift index by desired number of periods with an optional time freq.
skew([axis, skipna, level, numeric_only]) Return unbiased skew over requested axis.
slice_shift([periods, axis]) (DEPRECATED) Equivalent to shift without copying data.
sort_index([axis, level, ascending, ...]) Sort Series by index labels.
sort_values([axis, ascending, inplace, ...]) Sort by the values.
sparse alias of pandas.core.arrays.sparse.accessor.SparseAccessor
squeeze([axis]) Squeeze 1 dimensional axis objects into scalars.
std([axis, skipna, level, ddof, numeric_only]) Return sample standard deviation over requested axis.
str alias of pandas.core.strings.accessor.StringMethods
sub(other[, level, fill_value, axis]) Return Subtraction of series and other, element-wise (binary operator sub).
subtract(other[, level, fill_value, axis]) Return Subtraction of series and other, element-wise (binary operator sub).
sum([axis, skipna, level, numeric_only, ...]) Return the sum of the values over the requested axis.
swapaxes(axis1, axis2[, copy]) Interchange axes and swap values axes appropriately.
swaplevel([i, j, copy]) Swap levels i and j in a MultiIndex.
tail([n]) Return the last n rows.
take(indices[, axis, is_copy]) Return the elements in the given positional indices along an axis.
to_clipboard([excel, sep]) Copy object to the system clipboard.
to_csv([path_or_buf, sep, na_rep, ...]) Write object to a comma-separated values (csv) file.
to_dict([into]) Convert Series to {label -> value} dict or dict-like object.
to_excel(excel_writer[, sheet_name, na_rep, ...]) Write object to an Excel sheet.
to_frame([name]) Convert Series to DataFrame.
to_hdf(path_or_buf, key[, mode, complevel, ...]) Write the contained data to an HDF5 file using HDFStore.
to_json([path_or_buf, orient, date_format, ...]) Convert the object to a JSON string.
to_latex([buf, columns, col_space, header, ...]) Render object to a LaTeX tabular, longtable, or nested table.
to_list() Return a list of the values.
to_markdown([buf, mode, index, storage_options]) Print Series in Markdown-friendly format.
to_numpy([dtype, copy, na_value]) A NumPy ndarray representing the values in this Series or Index.
to_period([freq, copy]) Convert Series from DatetimeIndex to PeriodIndex.
to_pickle(path[, compression, protocol, ...]) Pickle (serialize) object to file.
to_sql(name, con[, schema, if_exists, ...]) Write records stored in a DataFrame to a SQL database.
to_string([buf, na_rep, float_format, ...]) Render a string representation of the Series.
to_timestamp([freq, how, copy]) Cast to DatetimeIndex of Timestamps, at beginning of period.
to_xarray() Return an xarray object from the pandas object.
tolist() Return a list of the values.
transform(func[, axis]) Call func on self producing a Series with the same axis shape as self.
transpose(*args, **kwargs) Return the transpose, which is by definition self.
truediv(other[, level, fill_value, axis]) Return Floating division of series and other, element-wise (binary operator truediv).
truncate([before, after, axis, copy]) Truncate a Series or DataFrame before and after some index value.
tshift([periods, freq, axis]) (DEPRECATED) Shift the time index, using the index's frequency if available.
tz_convert(tz[, axis, level, copy]) Convert tz-aware axis to target time zone.
tz_localize(tz[, axis, level, copy, ...]) Localize tz-naive index of a Series or DataFrame to target time zone.
unique() Return unique values of Series object.
unstack([level, fill_value]) Unstack, also known as pivot, Series with MultiIndex to produce DataFrame.
update(other) Modify Series in place using values from passed Series.
value_counts([normalize, sort, ascending, ...]) Return a Series containing counts of unique values.
var([axis, skipna, level, ddof, numeric_only]) Return unbiased variance over requested axis.
view([dtype]) Create a new view of the Series.
where(cond[, other, inplace, axis, level, ...]) Replace values where the condition is False.
xs(key[, axis, level, drop_level]) Return cross-section from the Series/DataFrame.


pandas.Series.__array__   Series.__array__(dtype=None)[source]

Return the values as a NumPy array. Users should not call this directly. Rather, it is invoked by numpy.array() and numpy.asarray().  Parameters

dtype:str or numpy.dtype, optional

The dtype to use for the resulting NumPy array. By default, the dtype is inferred from the data.    Returns
 numpy.ndarray

The values in the series converted to a numpy.ndarray with the specified dtype.      See also  array

Create a new array from data.  Series.array

Zero-copy view to the array backing the Series.  Series.to_numpy

Series method for similar behavior.    Examples
>>> ser = pd.Series([1, 2, 3])
>>> np.asarray(ser)
array([1, 2, 3])
  For timezone-aware data, the timezones may be retained with dtype='object'
>>> tzser = pd.Series(pd.date_range('2000', periods=2, tz="CET"))
>>> np.asarray(tzser, dtype="object")
array([Timestamp('2000-01-01 00:00:00+0100', tz='CET'),
       Timestamp('2000-01-02 00:00:00+0100', tz='CET')],
      dtype=object)
  Or the values may be localized to UTC and the tzinfo discarded with dtype='datetime64[ns]'
>>> np.asarray(tzser, dtype="datetime64[ns]")
array(['1999-12-31T23:00:00.000000000', ...],
      dtype='datetime64[ns]')


pandas.Series.__iter__   Series.__iter__()[source]

Return an iterator of the values. These are each a scalar type, which is a Python scalar (for str, int, float) or a pandas scalar (for Timestamp/Timedelta/Interval/Period)  Returns
 iterator


pandas.Series.abs   Series.abs()[source]

Return a Series/DataFrame with absolute numeric value of each element. This function only applies to elements that are all numeric.  Returns
 abs

Series/DataFrame containing the absolute value of each element.      See also  numpy.absolute

Calculate the absolute value element-wise.    Notes For complex inputs, 1.2 + 1j, the absolute value is \(\sqrt{ a^2 + b^2 }\). Examples Absolute numeric values in a Series.
>>> s = pd.Series([-1.10, 2, -3.33, 4])
>>> s.abs()
0    1.10
1    2.00
2    3.33
3    4.00
dtype: float64
  Absolute numeric values in a Series with complex numbers.
>>> s = pd.Series([1.2 + 1j])
>>> s.abs()
0    1.56205
dtype: float64
  Absolute numeric values in a Series with a Timedelta element.
>>> s = pd.Series([pd.Timedelta('1 days')])
>>> s.abs()
0   1 days
dtype: timedelta64[ns]
  Select rows with data closest to certain value using argsort (from StackOverflow).
>>> df = pd.DataFrame({
...     'a': [4, 5, 6, 7],
...     'b': [10, 20, 30, 40],
...     'c': [100, 50, -30, -50]
... })
>>> df
     a    b    c
0    4   10  100
1    5   20   50
2    6   30  -30
3    7   40  -50
>>> df.loc[(df.c - 43).abs().argsort()]
     a    b    c
1    5   20   50
0    4   10  100
2    6   30  -30
3    7   40  -50


pandas.Series.add   Series.add(other, level=None, fill_value=None, axis=0)[source]

Return Addition of series and other, element-wise (binary operator add). Equivalent to series + other, but with support to substitute a fill_value for missing data in either one of the inputs.  Parameters

other:Series or scalar value

fill_value:None or float value, default None (NaN)

Fill existing missing (NaN) values, and any new element needed for successful Series alignment, with this value before computation. If data in both corresponding Series locations is missing the result of filling (at that location) will be missing.
level:int or name

Broadcast across a level, matching Index values on the passed MultiIndex level.    Returns
 Series

The result of the operation.      See also  Series.radd

Reverse of the Addition operator, see Python documentation for more details.    Examples
>>> a = pd.Series([1, 1, 1, np.nan], index=['a', 'b', 'c', 'd'])
>>> a
a    1.0
b    1.0
c    1.0
d    NaN
dtype: float64
>>> b = pd.Series([1, np.nan, 1, np.nan], index=['a', 'b', 'd', 'e'])
>>> b
a    1.0
b    NaN
d    1.0
e    NaN
dtype: float64
>>> a.add(b, fill_value=0)
a    2.0
b    1.0
c    1.0
d    1.0
e    NaN
dtype: float64


pandas.Series.add_prefix   Series.add_prefix(prefix)[source]

Prefix labels with string prefix. For Series, the row labels are prefixed. For DataFrame, the column labels are prefixed.  Parameters

prefix:str

The string to add before each label.    Returns
 Series or DataFrame

New Series or DataFrame with updated labels.      See also  Series.add_suffix

Suffix row labels with string suffix.  DataFrame.add_suffix

Suffix column labels with string suffix.    Examples
>>> s = pd.Series([1, 2, 3, 4])
>>> s
0    1
1    2
2    3
3    4
dtype: int64

>>> s.add_prefix('item_')
item_0    1
item_1    2
item_2    3
item_3    4
dtype: int64

>>> df = pd.DataFrame({'A': [1, 2, 3, 4], 'B': [3, 4, 5, 6]})
>>> df
   A  B
0  1  3
1  2  4
2  3  5
3  4  6

>>> df.add_prefix('col_')
     col_A  col_B
0       1       3
1       2       4
2       3       5
3       4       6


pandas.Series.add_suffix   Series.add_suffix(suffix)[source]

Suffix labels with string suffix. For Series, the row labels are suffixed. For DataFrame, the column labels are suffixed.  Parameters

suffix:str

The string to add after each label.    Returns
 Series or DataFrame

New Series or DataFrame with updated labels.      See also  Series.add_prefix

Prefix row labels with string prefix.  DataFrame.add_prefix

Prefix column labels with string prefix.    Examples
>>> s = pd.Series([1, 2, 3, 4])
>>> s
0    1
1    2
2    3
3    4
dtype: int64

>>> s.add_suffix('_item')
0_item    1
1_item    2
2_item    3
3_item    4
dtype: int64

>>> df = pd.DataFrame({'A': [1, 2, 3, 4], 'B': [3, 4, 5, 6]})
>>> df
   A  B
0  1  3
1  2  4
2  3  5
3  4  6

>>> df.add_suffix('_col')
     A_col  B_col
0       1       3
1       2       4
2       3       5
3       4       6


pandas.Series.agg   Series.agg(func=None, axis=0, *args, **kwargs)[source]

Aggregate using one or more operations over the specified axis.  Parameters

func:function, str, list or dict

Function to use for aggregating the data. If a function, must either work when passed a Series or when passed to Series.apply. Accepted combinations are:  function string function name list of functions and/or function names, e.g. [np.sum, 'mean'] dict of axis labels -> functions, function names or list of such.
axis:{0 or ‘index’}

Parameter needed for compatibility with DataFrame.  *args

Positional arguments to pass to func.  **kwargs

Keyword arguments to pass to func.    Returns
 scalar, Series or DataFrame

The return can be:  scalar : when Series.agg is called with single function Series : when DataFrame.agg is called with a single function DataFrame : when DataFrame.agg is called with several functions  Return scalar, Series or DataFrame.      See also  Series.apply

Invoke function on a Series.  Series.transform

Transform function producing a Series with like indexes.    Notes agg is an alias for aggregate. Use the alias. Functions that mutate the passed object can produce unexpected behavior or errors and are not supported. See Mutating with User Defined Function (UDF) methods for more details. A passed user-defined-function will be passed a Series for evaluation. Examples
>>> s = pd.Series([1, 2, 3, 4])
>>> s
0    1
1    2
2    3
3    4
dtype: int64

>>> s.agg('min')
1

>>> s.agg(['min', 'max'])
min   1
max   4
dtype: int64


pandas.Series.aggregate   Series.aggregate(func=None, axis=0, *args, **kwargs)[source]

Aggregate using one or more operations over the specified axis.  Parameters

func:function, str, list or dict

Function to use for aggregating the data. If a function, must either work when passed a Series or when passed to Series.apply. Accepted combinations are:  function string function name list of functions and/or function names, e.g. [np.sum, 'mean'] dict of axis labels -> functions, function names or list of such.
axis:{0 or ‘index’}

Parameter needed for compatibility with DataFrame.  *args

Positional arguments to pass to func.  **kwargs

Keyword arguments to pass to func.    Returns
 scalar, Series or DataFrame

The return can be:  scalar : when Series.agg is called with single function Series : when DataFrame.agg is called with a single function DataFrame : when DataFrame.agg is called with several functions  Return scalar, Series or DataFrame.      See also  Series.apply

Invoke function on a Series.  Series.transform

Transform function producing a Series with like indexes.    Notes agg is an alias for aggregate. Use the alias. Functions that mutate the passed object can produce unexpected behavior or errors and are not supported. See Mutating with User Defined Function (UDF) methods for more details. A passed user-defined-function will be passed a Series for evaluation. Examples
>>> s = pd.Series([1, 2, 3, 4])
>>> s
0    1
1    2
2    3
3    4
dtype: int64

>>> s.agg('min')
1

>>> s.agg(['min', 'max'])
min   1
max   4
dtype: int64


pandas.Series.align   Series.align(other, join='outer', axis=None, level=None, copy=True, fill_value=None, method=None, limit=None, fill_axis=0, broadcast_axis=None)[source]

Align two objects on their axes with the specified join method. Join method is specified for each axis Index.  Parameters

other:DataFrame or Series

join:{‘outer’, ‘inner’, ‘left’, ‘right’}, default ‘outer’

axis:allowed axis of the other object, default None

Align on index (0), columns (1), or both (None).
level:int or level name, default None

Broadcast across a level, matching Index values on the passed MultiIndex level.
copy:bool, default True

Always returns new objects. If copy=False and no reindexing is required then original objects are returned.
fill_value:scalar, default np.NaN

Value to use for missing values. Defaults to NaN, but can be any “compatible” value.
method:{‘backfill’, ‘bfill’, ‘pad’, ‘ffill’, None}, default None

Method to use for filling holes in reindexed Series:  pad / ffill: propagate last valid observation forward to next valid. backfill / bfill: use NEXT valid observation to fill gap.
limit:int, default None

If method is specified, this is the maximum number of consecutive NaN values to forward/backward fill. In other words, if there is a gap with more than this number of consecutive NaNs, it will only be partially filled. If method is not specified, this is the maximum number of entries along the entire axis where NaNs will be filled. Must be greater than 0 if not None.
fill_axis:{0 or ‘index’}, default 0

Filling axis, method and limit.
broadcast_axis:{0 or ‘index’}, default None

Broadcast values along this axis, if aligning two objects of different dimensions.    Returns

(left, right):(Series, type of other)

Aligned objects.     Examples
>>> df = pd.DataFrame(
...     [[1, 2, 3, 4], [6, 7, 8, 9]], columns=["D", "B", "E", "A"], index=[1, 2]
... )
>>> other = pd.DataFrame(
...     [[10, 20, 30, 40], [60, 70, 80, 90], [600, 700, 800, 900]],
...     columns=["A", "B", "C", "D"],
...     index=[2, 3, 4],
... )
>>> df
   D  B  E  A
1  1  2  3  4
2  6  7  8  9
>>> other
    A    B    C    D
2   10   20   30   40
3   60   70   80   90
4  600  700  800  900
  Align on columns:
>>> left, right = df.align(other, join="outer", axis=1)
>>> left
   A  B   C  D  E
1  4  2 NaN  1  3
2  9  7 NaN  6  8
>>> right
    A    B    C    D   E
2   10   20   30   40 NaN
3   60   70   80   90 NaN
4  600  700  800  900 NaN
  We can also align on the index:
>>> left, right = df.align(other, join="outer", axis=0)
>>> left
    D    B    E    A
1  1.0  2.0  3.0  4.0
2  6.0  7.0  8.0  9.0
3  NaN  NaN  NaN  NaN
4  NaN  NaN  NaN  NaN
>>> right
    A      B      C      D
1    NaN    NaN    NaN    NaN
2   10.0   20.0   30.0   40.0
3   60.0   70.0   80.0   90.0
4  600.0  700.0  800.0  900.0
  Finally, the default axis=None will align on both index and columns:
>>> left, right = df.align(other, join="outer", axis=None)
>>> left
     A    B   C    D    E
1  4.0  2.0 NaN  1.0  3.0
2  9.0  7.0 NaN  6.0  8.0
3  NaN  NaN NaN  NaN  NaN
4  NaN  NaN NaN  NaN  NaN
>>> right
       A      B      C      D   E
1    NaN    NaN    NaN    NaN NaN
2   10.0   20.0   30.0   40.0 NaN
3   60.0   70.0   80.0   90.0 NaN
4  600.0  700.0  800.0  900.0 NaN


pandas.Series.all   Series.all(axis=0, bool_only=None, skipna=True, level=None, **kwargs)[source]

Return whether all elements are True, potentially over an axis. Returns True unless there at least one element within a series or along a Dataframe axis that is False or equivalent (e.g. zero or empty).  Parameters

axis:{0 or ‘index’, 1 or ‘columns’, None}, default 0

Indicate which axis or axes should be reduced.  0 / ‘index’ : reduce the index, return a Series whose index is the original column labels. 1 / ‘columns’ : reduce the columns, return a Series whose index is the original index. None : reduce all axes, return a scalar.
bool_only:bool, default None

Include only boolean columns. If None, will attempt to use everything, then use only boolean data. Not implemented for Series.
skipna:bool, default True

Exclude NA/null values. If the entire row/column is NA and skipna is True, then the result will be True, as for an empty row/column. If skipna is False, then NA are treated as True, because these are not equal to zero.
level:int or level name, default None

If the axis is a MultiIndex (hierarchical), count along a particular level, collapsing into a scalar.
**kwargs:any, default None

Additional keywords have no effect but might be accepted for compatibility with NumPy.    Returns
 scalar or Series

If level is specified, then, Series is returned; otherwise, scalar is returned.      See also  Series.all

Return True if all elements are True.  DataFrame.any

Return True if one (or more) elements are True.    Examples Series
>>> pd.Series([True, True]).all()
True
>>> pd.Series([True, False]).all()
False
>>> pd.Series([], dtype="float64").all()
True
>>> pd.Series([np.nan]).all()
True
>>> pd.Series([np.nan]).all(skipna=False)
True
  DataFrames Create a dataframe from a dictionary.
>>> df = pd.DataFrame({'col1': [True, True], 'col2': [True, False]})
>>> df
   col1   col2
0  True   True
1  True  False
  Default behaviour checks if column-wise values all return True.
>>> df.all()
col1     True
col2    False
dtype: bool
  Specify axis='columns' to check if row-wise values all return True.
>>> df.all(axis='columns')
0     True
1    False
dtype: bool
  Or axis=None for whether every value is True.
>>> df.all(axis=None)
False


pandas.Series.any   Series.any(axis=0, bool_only=None, skipna=True, level=None, **kwargs)[source]

Return whether any element is True, potentially over an axis. Returns False unless there is at least one element within a series or along a Dataframe axis that is True or equivalent (e.g. non-zero or non-empty).  Parameters

axis:{0 or ‘index’, 1 or ‘columns’, None}, default 0

Indicate which axis or axes should be reduced.  0 / ‘index’ : reduce the index, return a Series whose index is the original column labels. 1 / ‘columns’ : reduce the columns, return a Series whose index is the original index. None : reduce all axes, return a scalar.
bool_only:bool, default None

Include only boolean columns. If None, will attempt to use everything, then use only boolean data. Not implemented for Series.
skipna:bool, default True

Exclude NA/null values. If the entire row/column is NA and skipna is True, then the result will be False, as for an empty row/column. If skipna is False, then NA are treated as True, because these are not equal to zero.
level:int or level name, default None

If the axis is a MultiIndex (hierarchical), count along a particular level, collapsing into a scalar.
**kwargs:any, default None

Additional keywords have no effect but might be accepted for compatibility with NumPy.    Returns
 scalar or Series

If level is specified, then, Series is returned; otherwise, scalar is returned.      See also  numpy.any

Numpy version of this method.  Series.any

Return whether any element is True.  Series.all

Return whether all elements are True.  DataFrame.any

Return whether any element is True over requested axis.  DataFrame.all

Return whether all elements are True over requested axis.    Examples Series For Series input, the output is a scalar indicating whether any element is True.
>>> pd.Series([False, False]).any()
False
>>> pd.Series([True, False]).any()
True
>>> pd.Series([], dtype="float64").any()
False
>>> pd.Series([np.nan]).any()
False
>>> pd.Series([np.nan]).any(skipna=False)
True
  DataFrame Whether each column contains at least one True element (the default).
>>> df = pd.DataFrame({"A": [1, 2], "B": [0, 2], "C": [0, 0]})
>>> df
   A  B  C
0  1  0  0
1  2  2  0

>>> df.any()
A     True
B     True
C    False
dtype: bool
  Aggregating over the columns.
>>> df = pd.DataFrame({"A": [True, False], "B": [1, 2]})
>>> df
       A  B
0   True  1
1  False  2

>>> df.any(axis='columns')
0    True
1    True
dtype: bool

>>> df = pd.DataFrame({"A": [True, False], "B": [1, 0]})
>>> df
       A  B
0   True  1
1  False  0

>>> df.any(axis='columns')
0    True
1    False
dtype: bool
  Aggregating over the entire DataFrame with axis=None.
>>> df.any(axis=None)
True
  any for an empty DataFrame is an empty Series.
>>> pd.DataFrame([]).any()
Series([], dtype: bool)


pandas.Series.append   Series.append(to_append, ignore_index=False, verify_integrity=False)[source]

Concatenate two or more Series.  Parameters

to_append:Series or list/tuple of Series

Series to append with self.
ignore_index:bool, default False

If True, the resulting axis will be labeled 0, 1, …, n - 1.
verify_integrity:bool, default False

If True, raise Exception on creating index with duplicates.    Returns
 Series

Concatenated Series.      See also  concat

General function to concatenate DataFrame or Series objects.    Notes Iteratively appending to a Series can be more computationally intensive than a single concatenate. A better solution is to append values to a list and then concatenate the list with the original Series all at once. Examples
>>> s1 = pd.Series([1, 2, 3])
>>> s2 = pd.Series([4, 5, 6])
>>> s3 = pd.Series([4, 5, 6], index=[3, 4, 5])
>>> s1.append(s2)
0    1
1    2
2    3
0    4
1    5
2    6
dtype: int64

>>> s1.append(s3)
0    1
1    2
2    3
3    4
4    5
5    6
dtype: int64
  With ignore_index set to True:
>>> s1.append(s2, ignore_index=True)
0    1
1    2
2    3
3    4
4    5
5    6
dtype: int64
  With verify_integrity set to True:
>>> s1.append(s2, verify_integrity=True)
Traceback (most recent call last):
...
ValueError: Indexes have overlapping values: [0, 1, 2]


pandas.Series.apply   Series.apply(func, convert_dtype=True, args=(), **kwargs)[source]

Invoke function on values of Series. Can be ufunc (a NumPy function that applies to the entire Series) or a Python function that only works on single values.  Parameters

func:function

Python function or NumPy ufunc to apply.
convert_dtype:bool, default True

Try to find better dtype for elementwise function results. If False, leave as dtype=object. Note that the dtype is always preserved for some extension array dtypes, such as Categorical.
args:tuple

Positional arguments passed to func after the series value.  **kwargs

Additional keyword arguments passed to func.    Returns
 Series or DataFrame

If func returns a Series object the result will be a DataFrame.      See also  Series.map

For element-wise operations.  Series.agg

Only perform aggregating type operations.  Series.transform

Only perform transforming type operations.    Notes Functions that mutate the passed object can produce unexpected behavior or errors and are not supported. See Mutating with User Defined Function (UDF) methods for more details. Examples Create a series with typical summer temperatures for each city.
>>> s = pd.Series([20, 21, 12],
...               index=['London', 'New York', 'Helsinki'])
>>> s
London      20
New York    21
Helsinki    12
dtype: int64
  Square the values by defining a function and passing it as an argument to apply().
>>> def square(x):
...     return x ** 2
>>> s.apply(square)
London      400
New York    441
Helsinki    144
dtype: int64
  Square the values by passing an anonymous function as an argument to apply().
>>> s.apply(lambda x: x ** 2)
London      400
New York    441
Helsinki    144
dtype: int64
  Define a custom function that needs additional positional arguments and pass these additional arguments using the args keyword.
>>> def subtract_custom_value(x, custom_value):
...     return x - custom_value

>>> s.apply(subtract_custom_value, args=(5,))
London      15
New York    16
Helsinki     7
dtype: int64
  Define a custom function that takes keyword arguments and pass these arguments to apply.
>>> def add_custom_values(x, **kwargs):
...     for month in kwargs:
...         x += kwargs[month]
...     return x

>>> s.apply(add_custom_values, june=30, july=20, august=25)
London      95
New York    96
Helsinki    87
dtype: int64
  Use a function from the Numpy library.
>>> s.apply(np.log)
London      2.995732
New York    3.044522
Helsinki    2.484907
dtype: float64


pandas.Series.argmax   Series.argmax(axis=None, skipna=True, *args, **kwargs)[source]

Return int position of the largest value in the Series. If the maximum is achieved in multiple locations, the first row position is returned.  Parameters

axis:{None}

Dummy argument for consistency with Series.
skipna:bool, default True

Exclude NA/null values when showing the result.  *args, **kwargs

Additional arguments and keywords for compatibility with NumPy.    Returns
 int

Row position of the maximum value.      See also  Series.argmax

Return position of the maximum value.  Series.argmin

Return position of the minimum value.  numpy.ndarray.argmax

Equivalent method for numpy arrays.  Series.idxmax

Return index label of the maximum values.  Series.idxmin

Return index label of the minimum values.    Examples Consider dataset containing cereal calories
>>> s = pd.Series({'Corn Flakes': 100.0, 'Almond Delight': 110.0,
...                'Cinnamon Toast Crunch': 120.0, 'Cocoa Puff': 110.0})
>>> s
Corn Flakes              100.0
Almond Delight           110.0
Cinnamon Toast Crunch    120.0
Cocoa Puff               110.0
dtype: float64

>>> s.argmax()
2
>>> s.argmin()
0
  The maximum cereal calories is the third element and the minimum cereal calories is the first element, since series is zero-indexed.


pandas.Series.argmin   Series.argmin(axis=None, skipna=True, *args, **kwargs)[source]

Return int position of the smallest value in the Series. If the minimum is achieved in multiple locations, the first row position is returned.  Parameters

axis:{None}

Dummy argument for consistency with Series.
skipna:bool, default True

Exclude NA/null values when showing the result.  *args, **kwargs

Additional arguments and keywords for compatibility with NumPy.    Returns
 int

Row position of the minimum value.      See also  Series.argmin

Return position of the minimum value.  Series.argmax

Return position of the maximum value.  numpy.ndarray.argmin

Equivalent method for numpy arrays.  Series.idxmax

Return index label of the maximum values.  Series.idxmin

Return index label of the minimum values.    Examples Consider dataset containing cereal calories
>>> s = pd.Series({'Corn Flakes': 100.0, 'Almond Delight': 110.0,
...                'Cinnamon Toast Crunch': 120.0, 'Cocoa Puff': 110.0})
>>> s
Corn Flakes              100.0
Almond Delight           110.0
Cinnamon Toast Crunch    120.0
Cocoa Puff               110.0
dtype: float64

>>> s.argmax()
2
>>> s.argmin()
0
  The maximum cereal calories is the third element and the minimum cereal calories is the first element, since series is zero-indexed.


pandas.Series.argsort   Series.argsort(axis=0, kind='quicksort', order=None)[source]

Return the integer indices that would sort the Series values. Override ndarray.argsort. Argsorts the value, omitting NA/null values, and places the result in the same locations as the non-NA values.  Parameters

axis:{0 or “index”}

Has no effect but is accepted for compatibility with numpy.
kind:{‘mergesort’, ‘quicksort’, ‘heapsort’, ‘stable’}, default ‘quicksort’

Choice of sorting algorithm. See numpy.sort() for more information. ‘mergesort’ and ‘stable’ are the only stable algorithms.
order:None

Has no effect but is accepted for compatibility with numpy.    Returns
 Series[np.intp]

Positions of values within the sort order with -1 indicating nan values.      See also  numpy.ndarray.argsort

Returns the indices that would sort this array.


pandas.Series.array   propertySeries.array

The ExtensionArray of the data backing this Series or Index.  Returns
 ExtensionArray

An ExtensionArray of the values stored within. For extension types, this is the actual array. For NumPy native types, this is a thin (no copy) wrapper around numpy.ndarray. .array differs .values which may require converting the data to a different form.      See also  Index.to_numpy

Similar method that always returns a NumPy array.  Series.to_numpy

Similar method that always returns a NumPy array.    Notes This table lays out the different array types for each extension dtype within pandas.
dtype array type
category Categorical
period PeriodArray
interval IntervalArray
IntegerNA IntegerArray
string StringArray
boolean BooleanArray
datetime64[ns, tz] DatetimeArray    For any 3rd-party extension types, the array type will be an ExtensionArray. For all remaining dtypes .array will be a arrays.NumpyExtensionArray wrapping the actual ndarray stored within. If you absolutely need a NumPy array (possibly with copying / coercing data), then use Series.to_numpy() instead. Examples For regular NumPy types like int, and float, a PandasArray is returned.
>>> pd.Series([1, 2, 3]).array
<PandasArray>
[1, 2, 3]
Length: 3, dtype: int64
  For extension types, like Categorical, the actual ExtensionArray is returned
>>> ser = pd.Series(pd.Categorical(['a', 'b', 'a']))
>>> ser.array
['a', 'b', 'a']
Categories (2, object): ['a', 'b']


pandas.Series.asfreq   Series.asfreq(freq, method=None, how=None, normalize=False, fill_value=None)[source]

Convert time series to specified frequency. Returns the original data conformed to a new index with the specified frequency. If the index of this Series is a PeriodIndex, the new index is the result of transforming the original index with PeriodIndex.asfreq (so the original index will map one-to-one to the new index). Otherwise, the new index will be equivalent to pd.date_range(start, end,
freq=freq) where start and end are, respectively, the first and last entries in the original index (see pandas.date_range()). The values corresponding to any timesteps in the new index which were not present in the original index will be null (NaN), unless a method for filling such unknowns is provided (see the method parameter below). The resample() method is more appropriate if an operation on each group of timesteps (such as an aggregate) is necessary to represent the data at the new frequency.  Parameters

freq:DateOffset or str

Frequency DateOffset or string.
method:{‘backfill’/’bfill’, ‘pad’/’ffill’}, default None

Method to use for filling holes in reindexed Series (note this does not fill NaNs that already were present):  ‘pad’ / ‘ffill’: propagate last valid observation forward to next valid ‘backfill’ / ‘bfill’: use NEXT valid observation to fill.
how:{‘start’, ‘end’}, default end

For PeriodIndex only (see PeriodIndex.asfreq).
normalize:bool, default False

Whether to reset output index to midnight.
fill_value:scalar, optional

Value to use for missing values, applied during upsampling (note this does not fill NaNs that already were present).    Returns
 Series

Series object reindexed to the specified frequency.      See also  reindex

Conform DataFrame to new index with optional filling logic.    Notes To learn more about the frequency strings, please see this link. Examples Start by creating a series with 4 one minute timestamps.
>>> index = pd.date_range('1/1/2000', periods=4, freq='T')
>>> series = pd.Series([0.0, None, 2.0, 3.0], index=index)
>>> df = pd.DataFrame({'s': series})
>>> df
                       s
2000-01-01 00:00:00    0.0
2000-01-01 00:01:00    NaN
2000-01-01 00:02:00    2.0
2000-01-01 00:03:00    3.0
  Upsample the series into 30 second bins.
>>> df.asfreq(freq='30S')
                       s
2000-01-01 00:00:00    0.0
2000-01-01 00:00:30    NaN
2000-01-01 00:01:00    NaN
2000-01-01 00:01:30    NaN
2000-01-01 00:02:00    2.0
2000-01-01 00:02:30    NaN
2000-01-01 00:03:00    3.0
  Upsample again, providing a fill value.
>>> df.asfreq(freq='30S', fill_value=9.0)
                       s
2000-01-01 00:00:00    0.0
2000-01-01 00:00:30    9.0
2000-01-01 00:01:00    NaN
2000-01-01 00:01:30    9.0
2000-01-01 00:02:00    2.0
2000-01-01 00:02:30    9.0
2000-01-01 00:03:00    3.0
  Upsample again, providing a method.
>>> df.asfreq(freq='30S', method='bfill')
                       s
2000-01-01 00:00:00    0.0
2000-01-01 00:00:30    NaN
2000-01-01 00:01:00    NaN
2000-01-01 00:01:30    2.0
2000-01-01 00:02:00    2.0
2000-01-01 00:02:30    3.0
2000-01-01 00:03:00    3.0


pandas.Series.asof   Series.asof(where, subset=None)[source]

Return the last row(s) without any NaNs before where. The last row (for each element in where, if list) without any NaN is taken. In case of a DataFrame, the last row without NaN considering only the subset of columns (if not None) If there is no good value, NaN is returned for a Series or a Series of NaN values for a DataFrame  Parameters

where:date or array-like of dates

Date(s) before which the last row(s) are returned.
subset:str or array-like of str, default None

For DataFrame, if not None, only use these columns to check for NaNs.    Returns
 scalar, Series, or DataFrame

The return can be:  scalar : when self is a Series and where is a scalar Series: when self is a Series and where is an array-like, or when self is a DataFrame and where is a scalar DataFrame : when self is a DataFrame and where is an array-like  Return scalar, Series, or DataFrame.      See also  merge_asof

Perform an asof merge. Similar to left join.    Notes Dates are assumed to be sorted. Raises if this is not the case. Examples A Series and a scalar where.
>>> s = pd.Series([1, 2, np.nan, 4], index=[10, 20, 30, 40])
>>> s
10    1.0
20    2.0
30    NaN
40    4.0
dtype: float64

>>> s.asof(20)
2.0
  For a sequence where, a Series is returned. The first value is NaN, because the first element of where is before the first index value.
>>> s.asof([5, 20])
5     NaN
20    2.0
dtype: float64
  Missing values are not considered. The following is 2.0, not NaN, even though NaN is at the index location for 30.
>>> s.asof(30)
2.0
  Take all columns into consideration
>>> df = pd.DataFrame({'a': [10, 20, 30, 40, 50],
...                    'b': [None, None, None, None, 500]},
...                   index=pd.DatetimeIndex(['2018-02-27 09:01:00',
...                                           '2018-02-27 09:02:00',
...                                           '2018-02-27 09:03:00',
...                                           '2018-02-27 09:04:00',
...                                           '2018-02-27 09:05:00']))
>>> df.asof(pd.DatetimeIndex(['2018-02-27 09:03:30',
...                           '2018-02-27 09:04:30']))
                      a   b
2018-02-27 09:03:30 NaN NaN
2018-02-27 09:04:30 NaN NaN
  Take a single column into consideration
>>> df.asof(pd.DatetimeIndex(['2018-02-27 09:03:30',
...                           '2018-02-27 09:04:30']),
...         subset=['a'])
                         a   b
2018-02-27 09:03:30   30.0 NaN
2018-02-27 09:04:30   40.0 NaN


pandas.Series.astype   Series.astype(dtype, copy=True, errors='raise')[source]

Cast a pandas object to a specified dtype dtype.  Parameters

dtype:data type, or dict of column name -> data type

Use a numpy.dtype or Python type to cast entire pandas object to the same type. Alternatively, use {col: dtype, …}, where col is a column label and dtype is a numpy.dtype or Python type to cast one or more of the DataFrame’s columns to column-specific types.
copy:bool, default True

Return a copy when copy=True (be very careful setting copy=False as changes to values then may propagate to other pandas objects).
errors:{‘raise’, ‘ignore’}, default ‘raise’

Control raising of exceptions on invalid data for provided dtype.  raise : allow exceptions to be raised ignore : suppress exceptions. On error return original object.     Returns

casted:same type as caller

    See also  to_datetime

Convert argument to datetime.  to_timedelta

Convert argument to timedelta.  to_numeric

Convert argument to a numeric type.  numpy.ndarray.astype

Cast a numpy array to a specified type.    Notes  Deprecated since version 1.3.0: Using astype to convert from timezone-naive dtype to timezone-aware dtype is deprecated and will raise in a future version. Use Series.dt.tz_localize() instead.  Examples Create a DataFrame:
>>> d = {'col1': [1, 2], 'col2': [3, 4]}
>>> df = pd.DataFrame(data=d)
>>> df.dtypes
col1    int64
col2    int64
dtype: object
  Cast all columns to int32:
>>> df.astype('int32').dtypes
col1    int32
col2    int32
dtype: object
  Cast col1 to int32 using a dictionary:
>>> df.astype({'col1': 'int32'}).dtypes
col1    int32
col2    int64
dtype: object
  Create a series:
>>> ser = pd.Series([1, 2], dtype='int32')
>>> ser
0    1
1    2
dtype: int32
>>> ser.astype('int64')
0    1
1    2
dtype: int64
  Convert to categorical type:
>>> ser.astype('category')
0    1
1    2
dtype: category
Categories (2, int64): [1, 2]
  Convert to ordered categorical type with custom ordering:
>>> 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]
  Note that using copy=False and changing data on a new pandas object may propagate changes:
>>> s1 = pd.Series([1, 2])
>>> s2 = s1.astype('int64', copy=False)
>>> s2[0] = 10
>>> s1  # note that s1[0] has changed too
0    10
1     2
dtype: int64
  Create a series of dates:
>>> 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[ns]


pandas.Series.at   propertySeries.at

Access a single value for a row/column label pair. Similar to loc, in that both provide label-based lookups. Use at if you only need to get or set a single value in a DataFrame or Series.  Raises
 KeyError

If ‘label’ does not exist in DataFrame.      See also  DataFrame.iat

Access a single value for a row/column pair by integer position.  DataFrame.loc

Access a group of rows and columns by label(s).  Series.at

Access a single value using a label.    Examples
>>> df = pd.DataFrame([[0, 2, 3], [0, 4, 1], [10, 20, 30]],
...                   index=[4, 5, 6], columns=['A', 'B', 'C'])
>>> df
    A   B   C
4   0   2   3
5   0   4   1
6  10  20  30
  Get value at specified row/column pair
>>> df.at[4, 'B']
2
  Set value at specified row/column pair
>>> df.at[4, 'B'] = 10
>>> df.at[4, 'B']
10
  Get value within a Series
>>> df.loc[5].at['B']
4


pandas.Series.at_time   Series.at_time(time, asof=False, axis=None)[source]

Select values at particular time of day (e.g., 9:30AM).  Parameters

time:datetime.time or str

axis:{0 or ‘index’, 1 or ‘columns’}, default 0

  Returns
 Series or DataFrame
  Raises
 TypeError

If the index is not a DatetimeIndex      See also  between_time

Select values between particular times of the day.  first

Select initial periods of time series based on a date offset.  last

Select final periods of time series based on a date offset.  DatetimeIndex.indexer_at_time

Get just the index locations for values at particular time of the day.    Examples
>>> i = pd.date_range('2018-04-09', periods=4, freq='12H')
>>> ts = pd.DataFrame({'A': [1, 2, 3, 4]}, index=i)
>>> ts
                     A
2018-04-09 00:00:00  1
2018-04-09 12:00:00  2
2018-04-10 00:00:00  3
2018-04-10 12:00:00  4

>>> ts.at_time('12:00')
                     A
2018-04-09 12:00:00  2
2018-04-10 12:00:00  4


pandas.Series.attrs   propertySeries.attrs

Dictionary of global attributes of this dataset.  Warning attrs is experimental and may change without warning.   See also  DataFrame.flags

Global flags applying to this object.


pandas.Series.autocorr   Series.autocorr(lag=1)[source]

Compute the lag-N autocorrelation. This method computes the Pearson correlation between the Series and its shifted self.  Parameters

lag:int, default 1

Number of lags to apply before performing autocorrelation.    Returns
 float

The Pearson correlation between self and self.shift(lag).      See also  Series.corr

Compute the correlation between two Series.  Series.shift

Shift index by desired number of periods.  DataFrame.corr

Compute pairwise correlation of columns.  DataFrame.corrwith

Compute pairwise correlation between rows or columns of two DataFrame objects.    Notes If the Pearson correlation is not well defined return ‘NaN’. Examples
>>> s = pd.Series([0.25, 0.5, 0.2, -0.05])
>>> s.autocorr()
0.10355...
>>> s.autocorr(lag=2)
-0.99999...
  If the Pearson correlation is not well defined, then ‘NaN’ is returned.
>>> s = pd.Series([1, 0, 0, 0])
>>> s.autocorr()
nan


pandas.Series.axes   propertySeries.axes

Return a list of the row axis labels.


pandas.Series.backfill   Series.backfill(axis=None, inplace=False, limit=None, downcast=None)[source]

Synonym for DataFrame.fillna() with method='bfill'.  Returns
 Series/DataFrame or None

Object with missing values filled or None if inplace=True.


pandas.Series.between   Series.between(left, right, inclusive='both')[source]

Return boolean Series equivalent to left <= series <= right. This function returns a boolean vector containing True wherever the corresponding Series element is between the boundary values left and right. NA values are treated as False.  Parameters

left:scalar or list-like

Left boundary.
right:scalar or list-like

Right boundary.
inclusive:{“both”, “neither”, “left”, “right”}

Include boundaries. Whether to set each bound as closed or open.  Changed in version 1.3.0.     Returns
 Series

Series representing whether each element is between left and right (inclusive).      See also  Series.gt

Greater than of series and other.  Series.lt

Less than of series and other.    Notes This function is equivalent to (left <= ser) & (ser <= right) Examples
>>> s = pd.Series([2, 0, 4, 8, np.nan])
  Boundary values are included by default:
>>> s.between(1, 4)
0     True
1    False
2     True
3    False
4    False
dtype: bool
  With inclusive set to "neither" boundary values are excluded:
>>> s.between(1, 4, inclusive="neither")
0     True
1    False
2    False
3    False
4    False
dtype: bool
  left and right can be any scalar value:
>>> s = pd.Series(['Alice', 'Bob', 'Carol', 'Eve'])
>>> s.between('Anna', 'Daniel')
0    False
1     True
2     True
3    False
dtype: bool


pandas.Series.between_time   Series.between_time(start_time, end_time, include_start=NoDefault.no_default, include_end=NoDefault.no_default, inclusive=None, axis=None)[source]

Select values between particular times of the day (e.g., 9:00-9:30 AM). By setting start_time to be later than end_time, you can get the times that are not between the two times.  Parameters

start_time:datetime.time or str

Initial time as a time filter limit.
end_time:datetime.time or str

End time as a time filter limit.
include_start:bool, default True

Whether the start time needs to be included in the result.  Deprecated since version 1.4.0: Arguments include_start and include_end have been deprecated to standardize boundary inputs. Use inclusive instead, to set each bound as closed or open.
include_end:bool, default True

Whether the end time needs to be included in the result.  Deprecated since version 1.4.0: Arguments include_start and include_end have been deprecated to standardize boundary inputs. Use inclusive instead, to set each bound as closed or open.
inclusive:{“both”, “neither”, “left”, “right”}, default “both”

Include boundaries; whether to set each bound as closed or open.
axis:{0 or ‘index’, 1 or ‘columns’}, default 0

Determine range time on index or columns value.    Returns
 Series or DataFrame

Data from the original object filtered to the specified dates range.    Raises
 TypeError

If the index is not a DatetimeIndex      See also  at_time

Select values at a particular time of the day.  first

Select initial periods of time series based on a date offset.  last

Select final periods of time series based on a date offset.  DatetimeIndex.indexer_between_time

Get just the index locations for values between particular times of the day.    Examples
>>> i = pd.date_range('2018-04-09', periods=4, freq='1D20min')
>>> ts = pd.DataFrame({'A': [1, 2, 3, 4]}, index=i)
>>> ts
                     A
2018-04-09 00:00:00  1
2018-04-10 00:20:00  2
2018-04-11 00:40:00  3
2018-04-12 01:00:00  4

>>> ts.between_time('0:15', '0:45')
                     A
2018-04-10 00:20:00  2
2018-04-11 00:40:00  3
  You get the times that are not between two times by setting start_time later than end_time:
>>> ts.between_time('0:45', '0:15')
                     A
2018-04-09 00:00:00  1
2018-04-12 01:00:00  4


pandas.Series.bfill   Series.bfill(axis=None, inplace=False, limit=None, downcast=None)[source]

Synonym for DataFrame.fillna() with method='bfill'.  Returns
 Series/DataFrame or None

Object with missing values filled or None if inplace=True.


pandas.Series.bool   Series.bool()[source]

Return the bool of a single element Series or DataFrame. This must be a boolean scalar value, either True or False. It will raise a ValueError if the Series or DataFrame does not have exactly 1 element, or that element is not boolean (integer values 0 and 1 will also raise an exception).  Returns
 bool

The value in the Series or DataFrame.      See also  Series.astype

Change the data type of a Series, including to boolean.  DataFrame.astype

Change the data type of a DataFrame, including to boolean.  numpy.bool_

NumPy boolean data type, used by pandas for boolean values.    Examples The method will only work for single element objects with a boolean value:
>>> pd.Series([True]).bool()
True
>>> pd.Series([False]).bool()
False

>>> pd.DataFrame({'col': [True]}).bool()
True
>>> pd.DataFrame({'col': [False]}).bool()
False


pandas.Series.cat   Series.cat()[source]

Accessor object for categorical properties of the Series values. Be aware that assigning to categories is a inplace operation, while all methods return new categorical data per default (but can be called with inplace=True).  Parameters

data:Series or CategoricalIndex

   Examples
>>> s = pd.Series(list("abbccc")).astype("category")
>>> s
0    a
1    b
2    b
3    c
4    c
5    c
dtype: category
Categories (3, object): ['a', 'b', 'c']

>>> s.cat.categories
Index(['a', 'b', 'c'], dtype='object')

>>> s.cat.rename_categories(list("cba"))
0    c
1    b
2    b
3    a
4    a
5    a
dtype: category
Categories (3, object): ['c', 'b', 'a']

>>> s.cat.reorder_categories(list("cba"))
0    a
1    b
2    b
3    c
4    c
5    c
dtype: category
Categories (3, object): ['c', 'b', 'a']

>>> s.cat.add_categories(["d", "e"])
0    a
1    b
2    b
3    c
4    c
5    c
dtype: category
Categories (5, object): ['a', 'b', 'c', 'd', 'e']

>>> s.cat.remove_categories(["a", "c"])
0    NaN
1      b
2      b
3    NaN
4    NaN
5    NaN
dtype: category
Categories (1, object): ['b']

>>> s1 = s.cat.add_categories(["d", "e"])
>>> s1.cat.remove_unused_categories()
0    a
1    b
2    b
3    c
4    c
5    c
dtype: category
Categories (3, object): ['a', 'b', 'c']

>>> s.cat.set_categories(list("abcde"))
0    a
1    b
2    b
3    c
4    c
5    c
dtype: category
Categories (5, object): ['a', 'b', 'c', 'd', 'e']

>>> s.cat.as_ordered()
0    a
1    b
2    b
3    c
4    c
5    c
dtype: category
Categories (3, object): ['a' < 'b' < 'c']

>>> s.cat.as_unordered()
0    a
1    b
2    b
3    c
4    c
5    c
dtype: category
Categories (3, object): ['a', 'b', 'c']


pandas.Series.cat.add_categories   Series.cat.add_categories(*args, **kwargs)[source]

Add new categories. new_categories will be included at the last/highest place in the categories and will be unused directly after this call.  Parameters

new_categories:category or list-like of category

The new categories to be included.
inplace:bool, default False

Whether or not to add the categories inplace or return a copy of this categorical with added categories.  Deprecated since version 1.3.0.     Returns

cat:Categorical or None

Categorical with new categories added or None if inplace=True.    Raises
 ValueError

If the new categories include old categories or do not validate as categories      See also  rename_categories

Rename categories.  reorder_categories

Reorder categories.  remove_categories

Remove the specified categories.  remove_unused_categories

Remove categories which are not used.  set_categories

Set the categories to the specified ones.    Examples
>>> c = pd.Categorical(['c', 'b', 'c'])
>>> c
['c', 'b', 'c']
Categories (2, object): ['b', 'c']

>>> c.add_categories(['d', 'a'])
['c', 'b', 'c']
Categories (4, object): ['b', 'c', 'd', 'a']


pandas.Series.cat.as_ordered   Series.cat.as_ordered(*args, **kwargs)[source]

Set the Categorical to be ordered.  Parameters

inplace:bool, default False

Whether or not to set the ordered attribute in-place or return a copy of this categorical with ordered set to True.    Returns
 Categorical or None

Ordered Categorical or None if inplace=True.


pandas.Series.cat.as_unordered   Series.cat.as_unordered(*args, **kwargs)[source]

Set the Categorical to be unordered.  Parameters

inplace:bool, default False

Whether or not to set the ordered attribute in-place or return a copy of this categorical with ordered set to False.    Returns
 Categorical or None

Unordered Categorical or None if inplace=True.


pandas.Series.cat.categories   Series.cat.categories

The categories of this categorical. Setting assigns new values to each category (effectively a rename of each individual category). The assigned value has to be a list-like object. All items must be unique and the number of items in the new categories must be the same as the number of items in the old categories. Assigning to categories is a inplace operation!  Raises
 ValueError

If the new categories do not validate as categories or if the number of new categories is unequal the number of old categories      See also  rename_categories

Rename categories.  reorder_categories

Reorder categories.  add_categories

Add new categories.  remove_categories

Remove the specified categories.  remove_unused_categories

Remove categories which are not used.  set_categories

Set the categories to the specified ones.


pandas.Series.cat.codes   Series.cat.codes

Return Series of codes as well as the index.


pandas.Series.cat.ordered   Series.cat.ordered

Whether the categories have an ordered relationship.


pandas.Series.cat.remove_categories   Series.cat.remove_categories(*args, **kwargs)[source]

Remove the specified categories. removals must be included in the old categories. Values which were in the removed categories will be set to NaN  Parameters

removals:category or list of categories

The categories which should be removed.
inplace:bool, default False

Whether or not to remove the categories inplace or return a copy of this categorical with removed categories.  Deprecated since version 1.3.0.     Returns

cat:Categorical or None

Categorical with removed categories or None if inplace=True.    Raises
 ValueError

If the removals are not contained in the categories      See also  rename_categories

Rename categories.  reorder_categories

Reorder categories.  add_categories

Add new categories.  remove_unused_categories

Remove categories which are not used.  set_categories

Set the categories to the specified ones.    Examples
>>> c = pd.Categorical(['a', 'c', 'b', 'c', 'd'])
>>> c
['a', 'c', 'b', 'c', 'd']
Categories (4, object): ['a', 'b', 'c', 'd']

>>> c.remove_categories(['d', 'a'])
[NaN, 'c', 'b', 'c', NaN]
Categories (2, object): ['b', 'c']


pandas.Series.cat.remove_unused_categories   Series.cat.remove_unused_categories(*args, **kwargs)[source]

Remove categories which are not used.  Parameters

inplace:bool, default False

Whether or not to drop unused categories inplace or return a copy of this categorical with unused categories dropped.  Deprecated since version 1.2.0.     Returns

cat:Categorical or None

Categorical with unused categories dropped or None if inplace=True.      See also  rename_categories

Rename categories.  reorder_categories

Reorder categories.  add_categories

Add new categories.  remove_categories

Remove the specified categories.  set_categories

Set the categories to the specified ones.    Examples
>>> c = pd.Categorical(['a', 'c', 'b', 'c', 'd'])
>>> c
['a', 'c', 'b', 'c', 'd']
Categories (4, object): ['a', 'b', 'c', 'd']

>>> c[2] = 'a'
>>> c[4] = 'c'
>>> c
['a', 'c', 'a', 'c', 'c']
Categories (4, object): ['a', 'b', 'c', 'd']

>>> c.remove_unused_categories()
['a', 'c', 'a', 'c', 'c']
Categories (2, object): ['a', 'c']


pandas.Series.cat.rename_categories   Series.cat.rename_categories(*args, **kwargs)[source]

Rename categories.  Parameters

new_categories:list-like, dict-like or callable

New categories which will replace old categories.  list-like: all items must be unique and the number of items in the new categories must match the existing number of categories. dict-like: specifies a mapping from old categories to new. Categories not contained in the mapping are passed through and extra categories in the mapping are ignored. callable : a callable that is called on all items in the old categories and whose return values comprise the new categories.
inplace:bool, default False

Whether or not to rename the categories inplace or return a copy of this categorical with renamed categories.  Deprecated since version 1.3.0.     Returns

cat:Categorical or None

Categorical with removed categories or None if inplace=True.    Raises
 ValueError

If new categories are list-like and do not have the same number of items than the current categories or do not validate as categories      See also  reorder_categories

Reorder categories.  add_categories

Add new categories.  remove_categories

Remove the specified categories.  remove_unused_categories

Remove categories which are not used.  set_categories

Set the categories to the specified ones.    Examples
>>> c = pd.Categorical(['a', 'a', 'b'])
>>> c.rename_categories([0, 1])
[0, 0, 1]
Categories (2, int64): [0, 1]
  For dict-like new_categories, extra keys are ignored and categories not in the dictionary are passed through
>>> c.rename_categories({'a': 'A', 'c': 'C'})
['A', 'A', 'b']
Categories (2, object): ['A', 'b']
  You may also provide a callable to create the new categories
>>> c.rename_categories(lambda x: x.upper())
['A', 'A', 'B']
Categories (2, object): ['A', 'B']


pandas.Series.cat.reorder_categories   Series.cat.reorder_categories(*args, **kwargs)[source]

Reorder categories as specified in new_categories. new_categories need to include all old categories and no new category items.  Parameters

new_categories:Index-like

The categories in new order.
ordered:bool, optional

Whether or not the categorical is treated as a ordered categorical. If not given, do not change the ordered information.
inplace:bool, default False

Whether or not to reorder the categories inplace or return a copy of this categorical with reordered categories.  Deprecated since version 1.3.0.     Returns

cat:Categorical or None

Categorical with removed categories or None if inplace=True.    Raises
 ValueError

If the new categories do not contain all old category items or any new ones      See also  rename_categories

Rename categories.  add_categories

Add new categories.  remove_categories

Remove the specified categories.  remove_unused_categories

Remove categories which are not used.  set_categories

Set the categories to the specified ones.


pandas.Series.cat.set_categories   Series.cat.set_categories(*args, **kwargs)[source]

Set the categories to the specified new_categories. new_categories can include new categories (which will result in unused categories) or remove old categories (which results in values set to NaN). If rename==True, the categories will simple be renamed (less or more items than in old categories will result in values set to NaN or in unused categories respectively). This method can be used to perform more than one action of adding, removing, and reordering simultaneously and is therefore faster than performing the individual steps via the more specialised methods. On the other hand this methods does not do checks (e.g., whether the old categories are included in the new categories on a reorder), which can result in surprising changes, for example when using special string dtypes, which does not considers a S1 string equal to a single char python string.  Parameters

new_categories:Index-like

The categories in new order.
ordered:bool, default False

Whether or not the categorical is treated as a ordered categorical. If not given, do not change the ordered information.
rename:bool, default False

Whether or not the new_categories should be considered as a rename of the old categories or as reordered categories.
inplace:bool, default False

Whether or not to reorder the categories in-place or return a copy of this categorical with reordered categories.  Deprecated since version 1.3.0.     Returns
 Categorical with reordered categories or None if inplace.
  Raises
 ValueError

If new_categories does not validate as categories      See also  rename_categories

Rename categories.  reorder_categories

Reorder categories.  add_categories

Add new categories.  remove_categories

Remove the specified categories.  remove_unused_categories

Remove categories which are not used.


pandas.Series.clip   Series.clip(lower=None, upper=None, axis=None, inplace=False, *args, **kwargs)[source]

Trim values at input threshold(s). Assigns values outside boundary to boundary values. Thresholds can be singular values or array like, and in the latter case the clipping is performed element-wise in the specified axis.  Parameters

lower:float or array-like, default None

Minimum threshold value. All values below this threshold will be set to it. A missing threshold (e.g NA) will not clip the value.
upper:float or array-like, default None

Maximum threshold value. All values above this threshold will be set to it. A missing threshold (e.g NA) will not clip the value.
axis:int or str axis name, optional

Align object with lower and upper along the given axis.
inplace:bool, default False

Whether to perform the operation in place on the data.  *args, **kwargs

Additional keywords have no effect but might be accepted for compatibility with numpy.    Returns
 Series or DataFrame or None

Same type as calling object with the values outside the clip boundaries replaced or None if inplace=True.      See also  Series.clip

Trim values at input threshold in series.  DataFrame.clip

Trim values at input threshold in dataframe.  numpy.clip

Clip (limit) the values in an array.    Examples
>>> data = {'col_0': [9, -3, 0, -1, 5], 'col_1': [-2, -7, 6, 8, -5]}
>>> df = pd.DataFrame(data)
>>> df
   col_0  col_1
0      9     -2
1     -3     -7
2      0      6
3     -1      8
4      5     -5
  Clips per column using lower and upper thresholds:
>>> df.clip(-4, 6)
   col_0  col_1
0      6     -2
1     -3     -4
2      0      6
3     -1      6
4      5     -4
  Clips using specific lower and upper thresholds per column element:
>>> t = pd.Series([2, -4, -1, 6, 3])
>>> t
0    2
1   -4
2   -1
3    6
4    3
dtype: int64

>>> df.clip(t, t + 4, axis=0)
   col_0  col_1
0      6      2
1     -3     -4
2      0      3
3      6      8
4      5      3
  Clips using specific lower threshold per column element, with missing values:
>>> t = pd.Series([2, -4, np.NaN, 6, 3])
>>> t
0    2.0
1   -4.0
2    NaN
3    6.0
4    3.0
dtype: float64

>>> df.clip(t, axis=0)
col_0  col_1
0      9      2
1     -3     -4
2      0      6
3      6      8
4      5      3


pandas.Series.combine   Series.combine(other, func, fill_value=None)[source]

Combine the Series with a Series or scalar according to func. Combine the Series and other using func to perform elementwise selection for combined Series. fill_value is assumed when value is missing at some index from one of the two objects being combined.  Parameters

other:Series or scalar

The value(s) to be combined with the Series.
func:function

Function that takes two scalars as inputs and returns an element.
fill_value:scalar, optional

The value to assume when an index is missing from one Series or the other. The default specifies to use the appropriate NaN value for the underlying dtype of the Series.    Returns
 Series

The result of combining the Series with the other object.      See also  Series.combine_first

Combine Series values, choosing the calling Series’ values first.    Examples Consider 2 Datasets s1 and s2 containing highest clocked speeds of different birds.
>>> s1 = pd.Series({'falcon': 330.0, 'eagle': 160.0})
>>> s1
falcon    330.0
eagle     160.0
dtype: float64
>>> s2 = pd.Series({'falcon': 345.0, 'eagle': 200.0, 'duck': 30.0})
>>> s2
falcon    345.0
eagle     200.0
duck       30.0
dtype: float64
  Now, to combine the two datasets and view the highest speeds of the birds across the two datasets
>>> s1.combine(s2, max)
duck        NaN
eagle     200.0
falcon    345.0
dtype: float64
  In the previous example, the resulting value for duck is missing, because the maximum of a NaN and a float is a NaN. So, in the example, we set fill_value=0, so the maximum value returned will be the value from some dataset.
>>> s1.combine(s2, max, fill_value=0)
duck       30.0
eagle     200.0
falcon    345.0
dtype: float64


pandas.Series.combine_first   Series.combine_first(other)[source]

Update null elements with value in the same location in ‘other’. Combine two Series objects by filling null values in one Series with non-null values from the other Series. Result index will be the union of the two indexes.  Parameters

other:Series

The value(s) to be used for filling null values.    Returns
 Series

The result of combining the provided Series with the other object.      See also  Series.combine

Perform element-wise operation on two Series using a given function.    Examples
>>> s1 = pd.Series([1, np.nan])
>>> s2 = pd.Series([3, 4, 5])
>>> s1.combine_first(s2)
0    1.0
1    4.0
2    5.0
dtype: float64
  Null values still persist if the location of that null value does not exist in other
>>> s1 = pd.Series({'falcon': np.nan, 'eagle': 160.0})
>>> s2 = pd.Series({'eagle': 200.0, 'duck': 30.0})
>>> s1.combine_first(s2)
duck       30.0
eagle     160.0
falcon      NaN
dtype: float64


pandas.Series.compare   Series.compare(other, align_axis=1, keep_shape=False, keep_equal=False)[source]

Compare to another Series and show the differences.  New in version 1.1.0.   Parameters

other:Series

Object to compare with.
align_axis:{0 or ‘index’, 1 or ‘columns’}, default 1

Determine which axis to align the comparison on.
 0, or ‘index’:Resulting differences are stacked vertically

with rows drawn alternately from self and other.
 1, or ‘columns’:Resulting differences are aligned horizontally

with columns drawn alternately from self and other.
keep_shape:bool, default False

If true, all rows and columns are kept. Otherwise, only the ones with different values are kept.
keep_equal:bool, default False

If true, the result keeps values that are equal. Otherwise, equal values are shown as NaNs.    Returns
 Series or DataFrame

If axis is 0 or ‘index’ the result will be a Series. The resulting index will be a MultiIndex with ‘self’ and ‘other’ stacked alternately at the inner level. If axis is 1 or ‘columns’ the result will be a DataFrame. It will have two columns namely ‘self’ and ‘other’.      See also  DataFrame.compare

Compare with another DataFrame and show differences.    Notes Matching NaNs will not appear as a difference. Examples
>>> s1 = pd.Series(["a", "b", "c", "d", "e"])
>>> s2 = pd.Series(["a", "a", "c", "b", "e"])
  Align the differences on columns
>>> s1.compare(s2)
  self other
1    b     a
3    d     b
  Stack the differences on indices
>>> s1.compare(s2, align_axis=0)
1  self     b
   other    a
3  self     d
   other    b
dtype: object
  Keep all original rows
>>> s1.compare(s2, keep_shape=True)
  self other
0  NaN   NaN
1    b     a
2  NaN   NaN
3    d     b
4  NaN   NaN
  Keep all original rows and also all original values
>>> s1.compare(s2, keep_shape=True, keep_equal=True)
  self other
0    a     a
1    b     a
2    c     c
3    d     b
4    e     e


pandas.Series.convert_dtypes   Series.convert_dtypes(infer_objects=True, convert_string=True, convert_integer=True, convert_boolean=True, convert_floating=True)[source]

Convert columns to best possible dtypes using dtypes supporting pd.NA.  New in version 1.0.0.   Parameters

infer_objects:bool, default True

Whether object dtypes should be converted to the best possible types.
convert_string:bool, default True

Whether object dtypes should be converted to StringDtype().
convert_integer:bool, default True

Whether, if possible, conversion can be done to integer extension types.
convert_boolean:bool, defaults True

Whether object dtypes should be converted to BooleanDtypes().
convert_floating:bool, defaults True

Whether, if possible, conversion can be done to floating extension types. If convert_integer is also True, preference will be give to integer dtypes if the floats can be faithfully casted to integers.  New in version 1.2.0.     Returns
 Series or DataFrame

Copy of input object with new dtype.      See also  infer_objects

Infer dtypes of objects.  to_datetime

Convert argument to datetime.  to_timedelta

Convert argument to timedelta.  to_numeric

Convert argument to a numeric type.    Notes By default, convert_dtypes will attempt to convert a Series (or each Series in a DataFrame) to dtypes that support pd.NA. By using the options convert_string, convert_integer, convert_boolean and convert_boolean, it is possible to turn off individual conversions to StringDtype, the integer extension types, BooleanDtype or floating extension types, respectively. For object-dtyped columns, if infer_objects is True, use the inference rules as during normal Series/DataFrame construction. Then, if possible, convert to StringDtype, BooleanDtype or an appropriate integer or floating extension type, otherwise leave as object. If the dtype is integer, convert to an appropriate integer extension type. If the dtype is numeric, and consists of all integers, convert to an appropriate integer extension type. Otherwise, convert to an appropriate floating extension type.  Changed in version 1.2: Starting with pandas 1.2, this method also converts float columns to the nullable floating extension type.  In the future, as new dtypes are added that support pd.NA, the results of this method will change to support those new dtypes. Examples
>>> df = pd.DataFrame(
...     {
...         "a": pd.Series([1, 2, 3], dtype=np.dtype("int32")),
...         "b": pd.Series(["x", "y", "z"], dtype=np.dtype("O")),
...         "c": pd.Series([True, False, np.nan], dtype=np.dtype("O")),
...         "d": pd.Series(["h", "i", np.nan], dtype=np.dtype("O")),
...         "e": pd.Series([10, np.nan, 20], dtype=np.dtype("float")),
...         "f": pd.Series([np.nan, 100.5, 200], dtype=np.dtype("float")),
...     }
... )
  Start with a DataFrame with default dtypes.
>>> df
   a  b      c    d     e      f
0  1  x   True    h  10.0    NaN
1  2  y  False    i   NaN  100.5
2  3  z    NaN  NaN  20.0  200.0

>>> df.dtypes
a      int32
b     object
c     object
d     object
e    float64
f    float64
dtype: object
  Convert the DataFrame to use best possible dtypes.
>>> dfn = df.convert_dtypes()
>>> dfn
   a  b      c     d     e      f
0  1  x   True     h    10   <NA>
1  2  y  False     i  <NA>  100.5
2  3  z   <NA>  <NA>    20  200.0

>>> dfn.dtypes
a      Int32
b     string
c    boolean
d     string
e      Int64
f    Float64
dtype: object
  Start with a Series of strings and missing data represented by np.nan.
>>> s = pd.Series(["a", "b", np.nan])
>>> s
0      a
1      b
2    NaN
dtype: object
  Obtain a Series with dtype StringDtype.
>>> s.convert_dtypes()
0       a
1       b
2    <NA>
dtype: string


pandas.Series.copy   Series.copy(deep=True)[source]

Make a copy of this object’s indices and data. When deep=True (default), a new object will be created with a copy of the calling object’s data and indices. Modifications to the data or indices of the copy will not be reflected in the original object (see notes below). When deep=False, a new object will be created without copying the calling object’s data or index (only references to the data and index are copied). Any changes to the data of the original will be reflected in the shallow copy (and vice versa).  Parameters

deep:bool, default True

Make a deep copy, including a copy of the data and the indices. With deep=False neither the indices nor the data are copied.    Returns

copy:Series or DataFrame

Object type matches caller.     Notes When deep=True, data is copied but actual Python objects will not be copied recursively, only the reference to the object. This is in contrast to copy.deepcopy in the Standard Library, which recursively copies object data (see examples below). While Index objects are copied when deep=True, the underlying numpy array is not copied for performance reasons. Since Index is immutable, the underlying data can be safely shared and a copy is not needed. Examples
>>> s = pd.Series([1, 2], index=["a", "b"])
>>> s
a    1
b    2
dtype: int64

>>> s_copy = s.copy()
>>> s_copy
a    1
b    2
dtype: int64
  Shallow copy versus default (deep) copy:
>>> s = pd.Series([1, 2], index=["a", "b"])
>>> deep = s.copy()
>>> shallow = s.copy(deep=False)
  Shallow copy shares data and index with original.
>>> s is shallow
False
>>> s.values is shallow.values and s.index is shallow.index
True
  Deep copy has own copy of data and index.
>>> s is deep
False
>>> s.values is deep.values or s.index is deep.index
False
  Updates to the data shared by shallow copy and original is reflected in both; deep copy remains unchanged.
>>> s[0] = 3
>>> shallow[1] = 4
>>> s
a    3
b    4
dtype: int64
>>> shallow
a    3
b    4
dtype: int64
>>> deep
a    1
b    2
dtype: int64
  Note that when copying an object containing Python objects, a deep copy will copy the data, but will not do so recursively. Updating a nested data object will be reflected in the deep copy.
>>> s = pd.Series([[1, 2], [3, 4]])
>>> deep = s.copy()
>>> s[0][0] = 10
>>> s
0    [10, 2]
1     [3, 4]
dtype: object
>>> deep
0    [10, 2]
1     [3, 4]
dtype: object


pandas.Series.corr   Series.corr(other, method='pearson', min_periods=None)[source]

Compute correlation with other Series, excluding missing values.  Parameters

other:Series

Series with which to compute the correlation.
method:{‘pearson’, ‘kendall’, ‘spearman’} or callable

Method used to compute correlation:  pearson : Standard correlation coefficient kendall : Kendall Tau correlation coefficient spearman : Spearman rank correlation callable: Callable with input two 1d ndarrays and returning a float.   Warning Note that the returned matrix from corr will have 1 along the diagonals and will be symmetric regardless of the callable’s behavior.
min_periods:int, optional

Minimum number of observations needed to have a valid result.    Returns
 float

Correlation with other.      See also  DataFrame.corr

Compute pairwise correlation between columns.  DataFrame.corrwith

Compute pairwise correlation with another DataFrame or Series.    Examples
>>> def histogram_intersection(a, b):
...     v = np.minimum(a, b).sum().round(decimals=1)
...     return v
>>> s1 = pd.Series([.2, .0, .6, .2])
>>> s2 = pd.Series([.3, .6, .0, .1])
>>> s1.corr(s2, method=histogram_intersection)
0.3


pandas.Series.count   Series.count(level=None)[source]

Return number of non-NA/null observations in the Series.  Parameters

level:int or level name, default None

If the axis is a MultiIndex (hierarchical), count along a particular level, collapsing into a smaller Series.    Returns
 int or Series (if level specified)

Number of non-null values in the Series.      See also  DataFrame.count

Count non-NA cells for each column or row.    Examples
>>> s = pd.Series([0.0, 1.0, np.nan])
>>> s.count()
2


pandas.Series.cov   Series.cov(other, min_periods=None, ddof=1)[source]

Compute covariance with Series, excluding missing values.  Parameters

other:Series

Series with which to compute the covariance.
min_periods:int, optional

Minimum number of observations needed to have a valid result.
ddof:int, default 1

Delta degrees of freedom. The divisor used in calculations is N - ddof, where N represents the number of elements.  New in version 1.1.0.     Returns
 float

Covariance between Series and other normalized by N-1 (unbiased estimator).      See also  DataFrame.cov

Compute pairwise covariance of columns.    Examples
>>> s1 = pd.Series([0.90010907, 0.13484424, 0.62036035])
>>> s2 = pd.Series([0.12528585, 0.26962463, 0.51111198])
>>> s1.cov(s2)
-0.01685762652715874


pandas.Series.cummax   Series.cummax(axis=None, skipna=True, *args, **kwargs)[source]

Return cumulative maximum over a DataFrame or Series axis. Returns a DataFrame or Series of the same size containing the cumulative maximum.  Parameters

axis:{0 or ‘index’, 1 or ‘columns’}, default 0

The index or the name of the axis. 0 is equivalent to None or ‘index’.
skipna:bool, default True

Exclude NA/null values. If an entire row/column is NA, the result will be NA.  *args, **kwargs

Additional keywords have no effect but might be accepted for compatibility with NumPy.    Returns
 scalar or Series

Return cumulative maximum of scalar or Series.      See also  core.window.Expanding.max

Similar functionality but ignores NaN values.  Series.max

Return the maximum over Series axis.  Series.cummax

Return cumulative maximum over Series axis.  Series.cummin

Return cumulative minimum over Series axis.  Series.cumsum

Return cumulative sum over Series axis.  Series.cumprod

Return cumulative product over Series axis.    Examples Series
>>> s = pd.Series([2, np.nan, 5, -1, 0])
>>> s
0    2.0
1    NaN
2    5.0
3   -1.0
4    0.0
dtype: float64
  By default, NA values are ignored.
>>> s.cummax()
0    2.0
1    NaN
2    5.0
3    5.0
4    5.0
dtype: float64
  To include NA values in the operation, use skipna=False
>>> s.cummax(skipna=False)
0    2.0
1    NaN
2    NaN
3    NaN
4    NaN
dtype: float64
  DataFrame
>>> df = pd.DataFrame([[2.0, 1.0],
...                    [3.0, np.nan],
...                    [1.0, 0.0]],
...                    columns=list('AB'))
>>> df
     A    B
0  2.0  1.0
1  3.0  NaN
2  1.0  0.0
  By default, iterates over rows and finds the maximum in each column. This is equivalent to axis=None or axis='index'.
>>> df.cummax()
     A    B
0  2.0  1.0
1  3.0  NaN
2  3.0  1.0
  To iterate over columns and find the maximum in each row, use axis=1
>>> df.cummax(axis=1)
     A    B
0  2.0  2.0
1  3.0  NaN
2  1.0  1.0


pandas.Series.cummin   Series.cummin(axis=None, skipna=True, *args, **kwargs)[source]

Return cumulative minimum over a DataFrame or Series axis. Returns a DataFrame or Series of the same size containing the cumulative minimum.  Parameters

axis:{0 or ‘index’, 1 or ‘columns’}, default 0

The index or the name of the axis. 0 is equivalent to None or ‘index’.
skipna:bool, default True

Exclude NA/null values. If an entire row/column is NA, the result will be NA.  *args, **kwargs

Additional keywords have no effect but might be accepted for compatibility with NumPy.    Returns
 scalar or Series

Return cumulative minimum of scalar or Series.      See also  core.window.Expanding.min

Similar functionality but ignores NaN values.  Series.min

Return the minimum over Series axis.  Series.cummax

Return cumulative maximum over Series axis.  Series.cummin

Return cumulative minimum over Series axis.  Series.cumsum

Return cumulative sum over Series axis.  Series.cumprod

Return cumulative product over Series axis.    Examples Series
>>> s = pd.Series([2, np.nan, 5, -1, 0])
>>> s
0    2.0
1    NaN
2    5.0
3   -1.0
4    0.0
dtype: float64
  By default, NA values are ignored.
>>> s.cummin()
0    2.0
1    NaN
2    2.0
3   -1.0
4   -1.0
dtype: float64
  To include NA values in the operation, use skipna=False
>>> s.cummin(skipna=False)
0    2.0
1    NaN
2    NaN
3    NaN
4    NaN
dtype: float64
  DataFrame
>>> df = pd.DataFrame([[2.0, 1.0],
...                    [3.0, np.nan],
...                    [1.0, 0.0]],
...                    columns=list('AB'))
>>> df
     A    B
0  2.0  1.0
1  3.0  NaN
2  1.0  0.0
  By default, iterates over rows and finds the minimum in each column. This is equivalent to axis=None or axis='index'.
>>> df.cummin()
     A    B
0  2.0  1.0
1  2.0  NaN
2  1.0  0.0
  To iterate over columns and find the minimum in each row, use axis=1
>>> df.cummin(axis=1)
     A    B
0  2.0  1.0
1  3.0  NaN
2  1.0  0.0


pandas.Series.cumprod   Series.cumprod(axis=None, skipna=True, *args, **kwargs)[source]

Return cumulative product over a DataFrame or Series axis. Returns a DataFrame or Series of the same size containing the cumulative product.  Parameters

axis:{0 or ‘index’, 1 or ‘columns’}, default 0

The index or the name of the axis. 0 is equivalent to None or ‘index’.
skipna:bool, default True

Exclude NA/null values. If an entire row/column is NA, the result will be NA.  *args, **kwargs

Additional keywords have no effect but might be accepted for compatibility with NumPy.    Returns
 scalar or Series

Return cumulative product of scalar or Series.      See also  core.window.Expanding.prod

Similar functionality but ignores NaN values.  Series.prod

Return the product over Series axis.  Series.cummax

Return cumulative maximum over Series axis.  Series.cummin

Return cumulative minimum over Series axis.  Series.cumsum

Return cumulative sum over Series axis.  Series.cumprod

Return cumulative product over Series axis.    Examples Series
>>> s = pd.Series([2, np.nan, 5, -1, 0])
>>> s
0    2.0
1    NaN
2    5.0
3   -1.0
4    0.0
dtype: float64
  By default, NA values are ignored.
>>> s.cumprod()
0     2.0
1     NaN
2    10.0
3   -10.0
4    -0.0
dtype: float64
  To include NA values in the operation, use skipna=False
>>> s.cumprod(skipna=False)
0    2.0
1    NaN
2    NaN
3    NaN
4    NaN
dtype: float64
  DataFrame
>>> df = pd.DataFrame([[2.0, 1.0],
...                    [3.0, np.nan],
...                    [1.0, 0.0]],
...                    columns=list('AB'))
>>> df
     A    B
0  2.0  1.0
1  3.0  NaN
2  1.0  0.0
  By default, iterates over rows and finds the product in each column. This is equivalent to axis=None or axis='index'.
>>> df.cumprod()
     A    B
0  2.0  1.0
1  6.0  NaN
2  6.0  0.0
  To iterate over columns and find the product in each row, use axis=1
>>> df.cumprod(axis=1)
     A    B
0  2.0  2.0
1  3.0  NaN
2  1.0  0.0


pandas.Series.cumsum   Series.cumsum(axis=None, skipna=True, *args, **kwargs)[source]

Return cumulative sum over a DataFrame or Series axis. Returns a DataFrame or Series of the same size containing the cumulative sum.  Parameters

axis:{0 or ‘index’, 1 or ‘columns’}, default 0

The index or the name of the axis. 0 is equivalent to None or ‘index’.
skipna:bool, default True

Exclude NA/null values. If an entire row/column is NA, the result will be NA.  *args, **kwargs

Additional keywords have no effect but might be accepted for compatibility with NumPy.    Returns
 scalar or Series

Return cumulative sum of scalar or Series.      See also  core.window.Expanding.sum

Similar functionality but ignores NaN values.  Series.sum

Return the sum over Series axis.  Series.cummax

Return cumulative maximum over Series axis.  Series.cummin

Return cumulative minimum over Series axis.  Series.cumsum

Return cumulative sum over Series axis.  Series.cumprod

Return cumulative product over Series axis.    Examples Series
>>> s = pd.Series([2, np.nan, 5, -1, 0])
>>> s
0    2.0
1    NaN
2    5.0
3   -1.0
4    0.0
dtype: float64
  By default, NA values are ignored.
>>> s.cumsum()
0    2.0
1    NaN
2    7.0
3    6.0
4    6.0
dtype: float64
  To include NA values in the operation, use skipna=False
>>> s.cumsum(skipna=False)
0    2.0
1    NaN
2    NaN
3    NaN
4    NaN
dtype: float64
  DataFrame
>>> df = pd.DataFrame([[2.0, 1.0],
...                    [3.0, np.nan],
...                    [1.0, 0.0]],
...                    columns=list('AB'))
>>> df
     A    B
0  2.0  1.0
1  3.0  NaN
2  1.0  0.0
  By default, iterates over rows and finds the sum in each column. This is equivalent to axis=None or axis='index'.
>>> df.cumsum()
     A    B
0  2.0  1.0
1  5.0  NaN
2  6.0  1.0
  To iterate over columns and find the sum in each row, use axis=1
>>> df.cumsum(axis=1)
     A    B
0  2.0  3.0
1  3.0  NaN
2  1.0  1.0