pandas.
Series
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.
Contains data stored in Series.
Changed in version 0.23.0: If data is a dict, argument order is maintained for Python 3.6 and later.
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 both a dict and index sequence are used, the index will override the keys found in the dict.
Data type for the output Series. If not specified, this will be inferred from data. See the user guide for more usages.
The name to give to the Series.
Copy input data.
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 on this object.
axes
Return a list of the row axis labels.
dtype
Return the dtype object of the underlying data.
dtypes
hasnans
Return if I have any nans; enables various perf speedups.
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
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.
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
name
Methods
abs(self)
abs
Return a Series/DataFrame with absolute numeric value of each element.
add(self, other[, level, fill_value, axis])
add
Return Addition of series and other, element-wise (binary operator add).
add_prefix(self, prefix)
add_prefix
Prefix labels with string prefix.
add_suffix(self, suffix)
add_suffix
Suffix labels with string suffix.
agg(self, func[, axis])
agg
Aggregate using one or more operations over the specified axis.
aggregate(self, func[, axis])
aggregate
align(self, other[, join, axis, level, …])
align
Align two objects on their axes with the specified join method.
all(self[, axis, bool_only, skipna, level])
all
Return whether all elements are True, potentially over an axis.
any(self[, axis, bool_only, skipna, level])
any
Return whether any element is True, potentially over an axis.
append(self, to_append[, ignore_index, …])
append
Concatenate two or more Series.
apply(self, func[, convert_dtype, args])
apply
Invoke function on values of Series.
argmax(self[, axis, skipna])
argmax
Return an ndarray of the maximum argument indexer.
argmin(self[, axis, skipna])
argmin
Return a ndarray of the minimum argument indexer.
argsort(self[, axis, kind, order])
argsort
Override ndarray.argsort.
asfreq(self, freq[, method, fill_value])
asfreq
Convert TimeSeries to specified frequency.
asof(self, where[, subset])
asof
Return the last row(s) without any NaNs before where.
astype(self, dtype, copy, errors)
astype
Cast a pandas object to a specified dtype dtype.
at_time(self, time, asof[, axis])
at_time
Select values at particular time of day (e.g.
autocorr(self[, lag])
autocorr
Compute the lag-N autocorrelation.
between(self, left, right[, inclusive])
between
Return boolean Series equivalent to left <= series <= right.
between_time(self, start_time, end_time, …)
between_time
Select values between particular times of the day (e.g., 9:00-9:30 AM).
bfill(self[, axis, limit, downcast])
bfill
Synonym for DataFrame.fillna() with method='bfill'.
DataFrame.fillna()
method='bfill'
bool(self)
bool
Return the bool of a single element PandasObject.
cat
alias of pandas.core.arrays.categorical.CategoricalAccessor
pandas.core.arrays.categorical.CategoricalAccessor
clip(self[, lower, upper, axis])
clip
Trim values at input threshold(s).
combine(self, other, func[, fill_value])
combine
Combine the Series with a Series or scalar according to func.
combine_first(self, other)
combine_first
Combine Series values, choosing the calling Series’s values first.
copy(self, deep)
copy
Make a copy of this object’s indices and data.
corr(self, other[, method, min_periods])
corr
Compute correlation with other Series, excluding missing values.
count(self[, level])
count
Return number of non-NA/null observations in the Series.
cov(self, other[, min_periods])
cov
Compute covariance with Series, excluding missing values.
cummax(self[, axis, skipna])
cummax
Return cumulative maximum over a DataFrame or Series axis.
cummin(self[, axis, skipna])
cummin
Return cumulative minimum over a DataFrame or Series axis.
cumprod(self[, axis, skipna])
cumprod
Return cumulative product over a DataFrame or Series axis.
cumsum(self[, axis, skipna])
cumsum
Return cumulative sum over a DataFrame or Series axis.
describe(self[, percentiles, include, exclude])
describe
Generate descriptive statistics.
diff(self[, periods])
diff
First discrete difference of element.
div(self, other[, level, fill_value, axis])
div
Return Floating division of series and other, element-wise (binary operator truediv).
divide(self, other[, level, fill_value, axis])
divide
divmod(self, other[, level, fill_value, axis])
divmod
Return Integer division and modulo of series and other, element-wise (binary operator divmod).
dot(self, other)
dot
Compute the dot product between the Series and the columns of other.
drop(self[, labels, axis, index, columns, …])
drop
Return Series with specified index labels removed.
drop_duplicates(self[, keep, inplace])
drop_duplicates
Return Series with duplicate values removed.
droplevel(self, level[, axis])
droplevel
Return DataFrame with requested index / column level(s) removed.
dropna(self[, axis, inplace, how])
dropna
Return a new Series with missing values removed.
dt
alias of pandas.core.indexes.accessors.CombinedDatetimelikeProperties
pandas.core.indexes.accessors.CombinedDatetimelikeProperties
duplicated(self[, keep])
duplicated
Indicate duplicate Series values.
eq(self, other[, level, fill_value, axis])
eq
Return Equal to of series and other, element-wise (binary operator eq).
equals(self, other)
equals
Test whether two objects contain the same elements.
ewm(self[, com, span, halflife, alpha, …])
ewm
Provide exponential weighted functions.
expanding(self[, min_periods, center, axis])
expanding
Provide expanding transformations.
explode(self)
explode
Transform each element of a list-like to a row, replicating the index values.
factorize(self[, sort, na_sentinel])
factorize
Encode the object as an enumerated type or categorical variable.
ffill(self[, axis, limit, downcast])
ffill
Synonym for DataFrame.fillna() with method='ffill'.
method='ffill'
fillna(self[, value, method, axis, inplace, …])
fillna
Fill NA/NaN values using the specified method.
filter(self[, items, axis])
filter
Subset the dataframe rows or columns according to the specified index labels.
first(self, offset)
first
Method to subset initial periods of time series data based on a date offset.
first_valid_index(self)
first_valid_index
Return index for first non-NA/null value.
floordiv(self, other[, level, fill_value, axis])
floordiv
Return Integer division of series and other, element-wise (binary operator floordiv).
ge(self, other[, level, fill_value, axis])
ge
Return Greater than or equal to of series and other, element-wise (binary operator ge).
get(self, key[, default])
get
Get item from object for given key (ex: DataFrame column).
groupby(self[, by, axis, level])
groupby
Group Series using a mapper or by a Series of columns.
gt(self, other[, level, fill_value, axis])
gt
Return Greater than of series and other, element-wise (binary operator gt).
head(self, n)
head
Return the first n rows.
hist(self[, by, ax, grid, xlabelsize, xrot, …])
hist
Draw histogram of the input series using matplotlib.
idxmax(self[, axis, skipna])
idxmax
Return the row label of the maximum value.
idxmin(self[, axis, skipna])
idxmin
Return the row label of the minimum value.
infer_objects(self)
infer_objects
Attempt to infer better dtypes for object columns.
interpolate(self[, method, axis, limit, …])
interpolate
Interpolate values according to different methods.
isin(self, values)
isin
Check whether values are contained in Series.
isna(self)
isna
Detect missing values.
isnull(self)
isnull
item(self)
item
Return the first element of the underlying data as a python scalar.
items(self)
items
Lazily iterate over (index, value) tuples.
iteritems(self)
iteritems
keys(self)
keys
Return alias for index.
kurt(self[, axis, skipna, level, numeric_only])
kurt
Return unbiased kurtosis over requested axis.
kurtosis(self[, axis, skipna, level, …])
kurtosis
last(self, offset)
last
Method to subset final periods of time series data based on a date offset.
last_valid_index(self)
last_valid_index
Return index for last non-NA/null value.
le(self, other[, level, fill_value, axis])
le
Return Less than or equal to of series and other, element-wise (binary operator le).
lt(self, other[, level, fill_value, axis])
lt
Return Less than of series and other, element-wise (binary operator lt).
mad(self[, axis, skipna, level])
mad
Return the mean absolute deviation of the values for the requested axis.
map(self, arg[, na_action])
map
Map values of Series according to input correspondence.
mask(self, cond[, other, inplace, axis, …])
mask
Replace values where the condition is True.
max(self[, axis, skipna, level, numeric_only])
max
Return the maximum of the values for the requested axis.
mean(self[, axis, skipna, level, numeric_only])
mean
Return the mean of the values for the requested axis.
median(self[, axis, skipna, level, numeric_only])
median
Return the median of the values for the requested axis.
memory_usage(self[, index, deep])
memory_usage
Return the memory usage of the Series.
min(self[, axis, skipna, level, numeric_only])
min
Return the minimum of the values for the requested axis.
mod(self, other[, level, fill_value, axis])
mod
Return Modulo of series and other, element-wise (binary operator mod).
mode(self[, dropna])
mode
Return the mode(s) of the dataset.
mul(self, other[, level, fill_value, axis])
mul
Return Multiplication of series and other, element-wise (binary operator mul).
multiply(self, other[, level, fill_value, axis])
multiply
ne(self, other[, level, fill_value, axis])
ne
Return Not equal to of series and other, element-wise (binary operator ne).
nlargest(self[, n, keep])
nlargest
Return the largest n elements.
notna(self)
notna
Detect existing (non-missing) values.
notnull(self)
notnull
nsmallest(self[, n, keep])
nsmallest
Return the smallest n elements.
nunique(self[, dropna])
nunique
Return number of unique elements in the object.
pct_change(self[, periods, fill_method, …])
pct_change
Percentage change between the current and a prior element.
pipe(self, func, \*args, \*\*kwargs)
pipe
Apply func(self, *args, **kwargs).
plot
alias of pandas.plotting._core.PlotAccessor
pandas.plotting._core.PlotAccessor
pop(self, item)
pop
Return item and drop from frame.
pow(self, other[, level, fill_value, axis])
pow
Return Exponential power of series and other, element-wise (binary operator pow).
prod(self[, axis, skipna, level, …])
prod
Return the product of the values for the requested axis.
product(self[, axis, skipna, level, …])
product
quantile(self[, q, interpolation])
quantile
Return value at the given quantile.
radd(self, other[, level, fill_value, axis])
radd
Return Addition of series and other, element-wise (binary operator radd).
rank(self[, axis])
rank
Compute numerical data ranks (1 through n) along axis.
ravel(self[, order])
ravel
Return the flattened underlying data as an ndarray.
rdiv(self, other[, level, fill_value, axis])
rdiv
Return Floating division of series and other, element-wise (binary operator rtruediv).
rdivmod(self, other[, level, fill_value, axis])
rdivmod
Return Integer division and modulo of series and other, element-wise (binary operator rdivmod).
reindex(self[, index])
reindex
Conform Series to new index with optional filling logic.
reindex_like(self, other, method, …[, …])
reindex_like
Return an object with matching indices as other object.
rename(self[, index, axis, copy, inplace, …])
rename
Alter Series index labels or name.
rename_axis(self[, mapper, index, columns, …])
rename_axis
Set the name of the axis for the index or columns.
reorder_levels(self, order)
reorder_levels
Rearrange index levels using input order.
repeat(self, repeats[, axis])
repeat
Repeat elements of a Series.
replace(self[, to_replace, value, inplace, …])
replace
Replace values given in to_replace with value.
resample(self, rule[, axis, loffset, on, level])
resample
Resample time-series data.
reset_index(self[, level, drop, name, inplace])
reset_index
Generate a new DataFrame or Series with the index reset.
rfloordiv(self, other[, level, fill_value, axis])
rfloordiv
Return Integer division of series and other, element-wise (binary operator rfloordiv).
rmod(self, other[, level, fill_value, axis])
rmod
Return Modulo of series and other, element-wise (binary operator rmod).
rmul(self, other[, level, fill_value, axis])
rmul
Return Multiplication of series and other, element-wise (binary operator rmul).
rolling(self, window[, min_periods, center, …])
rolling
Provide rolling window calculations.
round(self[, decimals])
round
Round each value in a Series to the given number of decimals.
rpow(self, other[, level, fill_value, axis])
rpow
Return Exponential power of series and other, element-wise (binary operator rpow).
rsub(self, other[, level, fill_value, axis])
rsub
Return Subtraction of series and other, element-wise (binary operator rsub).
rtruediv(self, other[, level, fill_value, axis])
rtruediv
sample(self[, n, frac, replace, weights, …])
sample
Return a random sample of items from an axis of object.
searchsorted(self, value[, side, sorter])
searchsorted
Find indices where elements should be inserted to maintain order.
sem(self[, axis, skipna, level, ddof, …])
sem
Return unbiased standard error of the mean over requested axis.
set_axis(self, labels[, axis, inplace])
set_axis
Assign desired index to given axis.
shift(self[, periods, freq, axis, fill_value])
shift
Shift index by desired number of periods with an optional time freq.
skew(self[, axis, skipna, level, numeric_only])
skew
Return unbiased skew over requested axis.
slice_shift(self, periods[, axis])
slice_shift
Equivalent to shift without copying data.
sort_index(self[, axis, level, ascending, …])
sort_index
Sort Series by index labels.
sort_values(self[, axis, ascending])
sort_values
Sort by the values.
sparse
alias of pandas.core.arrays.sparse.accessor.SparseAccessor
pandas.core.arrays.sparse.accessor.SparseAccessor
squeeze(self[, axis])
squeeze
Squeeze 1 dimensional axis objects into scalars.
std(self[, axis, skipna, level, ddof, …])
std
Return sample standard deviation over requested axis.
str
alias of pandas.core.strings.StringMethods
pandas.core.strings.StringMethods
sub(self, other[, level, fill_value, axis])
sub
Return Subtraction of series and other, element-wise (binary operator sub).
subtract(self, other[, level, fill_value, axis])
subtract
sum(self[, axis, skipna, level, …])
sum
Return the sum of the values for the requested axis.
swapaxes(self, axis1, axis2[, copy])
swapaxes
Interchange axes and swap values axes appropriately.
swaplevel(self[, i, j, copy])
swaplevel
Swap levels i and j in a MultiIndex.
MultiIndex
tail(self, n)
tail
Return the last n rows.
take(self, indices[, axis, is_copy])
take
Return the elements in the given positional indices along an axis.
to_clipboard(self, excel, sep, …)
to_clipboard
Copy object to the system clipboard.
to_csv(self, path_or_buf, pathlib.Path, …)
to_csv
Write object to a comma-separated values (csv) file.
to_dict(self[, into])
to_dict
Convert Series to {label -> value} dict or dict-like object.
to_excel(self, excel_writer[, sheet_name, …])
to_excel
Write object to an Excel sheet.
to_frame(self[, name])
to_frame
Convert Series to DataFrame.
to_hdf(self, path_or_buf, key, mode, …[, …])
to_hdf
Write the contained data to an HDF5 file using HDFStore.
to_json(self, path_or_buf, pathlib.Path, …)
to_json
Convert the object to a JSON string.
to_latex(self[, buf, columns, col_space, …])
to_latex
Render object to a LaTeX tabular, longtable, or nested table/tabular.
to_list(self)
to_list
Return a list of the values.
to_markdown(self, buf, NoneType] = None, …)
to_markdown
Print Series in Markdown-friendly format.
to_numpy(self[, dtype, copy, na_value])
to_numpy
A NumPy ndarray representing the values in this Series or Index.
to_period(self[, freq, copy])
to_period
Convert Series from DatetimeIndex to PeriodIndex with desired frequency (inferred from index if not passed).
to_pickle(self, path, compression, …)
to_pickle
Pickle (serialize) object to file.
to_sql(self, name, con[, schema, …])
to_sql
Write records stored in a DataFrame to a SQL database.
to_string(self[, buf, na_rep, float_format, …])
to_string
Render a string representation of the Series.
to_timestamp(self[, freq, how, copy])
to_timestamp
Cast to DatetimeIndex of Timestamps, at beginning of period.
to_xarray(self)
to_xarray
Return an xarray object from the pandas object.
tolist(self)
tolist
transform(self, func[, axis])
transform
Call func on self producing a Series with transformed values.
func
transpose(self, \*args, \*\*kwargs)
transpose
truediv(self, other[, level, fill_value, axis])
truediv
truncate(self[, before, after, axis])
truncate
Truncate a Series or DataFrame before and after some index value.
tshift(self, periods[, freq, axis])
tshift
Shift the time index, using the index’s frequency if available.
tz_convert(self, tz[, axis, level])
tz_convert
Convert tz-aware axis to target time zone.
tz_localize(self, tz[, axis, level, ambiguous])
tz_localize
Localize tz-naive index of a Series or DataFrame to target time zone.
unique(self)
unique
Return unique values of Series object.
unstack(self[, level, fill_value])
unstack
Unstack, a.k.a.
update(self, other)
update
Modify Series in place using non-NA values from passed Series.
value_counts(self[, normalize, sort, …])
value_counts
Return a Series containing counts of unique values.
var(self[, axis, skipna, level, ddof, …])
var
Return unbiased variance over requested axis.
view(self[, dtype])
view
Create a new view of the Series.
where(self, cond[, other, inplace, axis, …])
where
Replace values where the condition is False.
xs(self, key[, axis, level])
xs
Return cross-section from the Series/DataFrame.