pandas.Series

class pandas.Series(data=None, index=None, dtype=None, name=None, copy=False, fastpath=False)

One-dimensional ndarray with axis labels (including time series).

Labels need not be unique but must be any 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, dict, or scalar value

Contains data stored in Series

index : array-like or Index (1d)

Values must be unique and hashable, same length as data. Index object (or other iterable of same length as data) Will default to RangeIndex(len(data)) if not provided. If both a dict and index sequence are used, the index will override the keys found in the dict.

dtype : numpy.dtype or None

If None, dtype will be inferred

copy : boolean, default False

Copy input data

Attributes

T return the transpose, which is by definition self
asobject return object Series which contains boxed values
at Fast label-based scalar accessor
axes Return a list of the row axis labels
base return the base object if the memory of the underlying data is
blocks Internal property, property synonym for as_blocks()
data return the data pointer of the underlying data
dtype return the dtype object of the underlying data
dtypes return the dtype object of the underlying data
empty True if NDFrame is entirely empty [no items], meaning any of the axes are of length 0.
flags
ftype return if the data is sparse|dense
ftypes return if the data is sparse|dense
hasnans
iat Fast integer location scalar accessor.
iloc Purely integer-location based indexing for selection by position.
imag
is_copy
is_time_series
is_unique Return boolean if values in the object are unique
itemsize return the size of the dtype of the item of the underlying data
ix A primarily label-location based indexer, with integer position fallback.
loc Purely label-location based indexer for selection by label.
name
nbytes return the number of bytes in the underlying data
ndim return the number of dimensions of the underlying data,
real
shape return a tuple of the shape of the underlying data
size return the number of elements in the underlying data
strides return the strides of the underlying data
values Return Series as ndarray or ndarray-like

Methods

abs() Return an object with absolute value taken–only applicable to objects that are all numeric.
add(other[, level, fill_value, axis]) Addition of series and other, element-wise (binary operator add).
add_prefix(prefix) Concatenate prefix string with panel items names.
add_suffix(suffix) Concatenate suffix string with panel items names.
align(other[, join, axis, level, copy, ...]) Align two object on their axes with the
all([axis, bool_only, skipna, level]) Return whether all elements are True over requested axis
any([axis, bool_only, skipna, level]) Return whether any element is True over requested axis
append(to_append[, verify_integrity]) Concatenate two or more Series.
apply(func[, convert_dtype, args]) Invoke function on values of Series.
argmax([axis, skipna]) Index of first occurrence of maximum of values.
argmin([axis, skipna]) Index of first occurrence of minimum of values.
argsort([axis, kind, order]) Overrides ndarray.argsort.
as_blocks([copy]) Convert the frame to a dict of dtype -> Constructor Types that each has a homogeneous dtype.
as_matrix([columns]) Convert the frame to its Numpy-array representation.
asfreq(freq[, method, how, normalize]) Convert all TimeSeries inside to specified frequency using DateOffset objects.
asof(where) Return last good (non-NaN) value in Series if value is NaN for requested date.
astype(dtype[, copy, raise_on_error]) Cast object to input numpy.dtype
at_time(time[, asof]) Select values at particular time of day (e.g.
autocorr([lag]) Lag-N autocorrelation
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 NDFrame.fillna(method=’bfill’)
bool() Return the bool of a single element PandasObject.
cat alias of CategoricalAccessor
clip([lower, upper, axis]) Trim values at input threshold(s).
clip_lower(threshold[, axis]) Return copy of the input with values below given value(s) truncated.
clip_upper(threshold[, axis]) Return copy of input with values above given value(s) truncated.
combine(other, func[, fill_value]) Perform elementwise binary operation on two Series using given function
combine_first(other) Combine Series values, choosing the calling Series’s values first.
compound([axis, skipna, level]) Return the compound percentage of the values for the requested axis
compress(condition, *args, **kwargs) Return selected slices of an array along given axis as a Series
consolidate([inplace]) Compute NDFrame with “consolidated” internals (data of each dtype grouped together in a single ndarray).
convert_objects([convert_dates, ...]) Deprecated.
copy([deep]) Make a copy of this objects 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]) Compute covariance with Series, excluding missing values
cummax([axis, dtype, out, skipna]) Return cumulative cummax over requested axis.
cummin([axis, dtype, out, skipna]) Return cumulative cummin over requested axis.
cumprod([axis, dtype, out, skipna]) Return cumulative cumprod over requested axis.
cumsum([axis, dtype, out, skipna]) Return cumulative cumsum over requested axis.
describe([percentiles, include, exclude]) Generate various summary statistics, excluding NaN values.
diff([periods]) 1st discrete difference of object
div(other[, level, fill_value, axis]) Floating division of series and other, element-wise (binary operator truediv).
divide(other[, level, fill_value, axis]) Floating division of series and other, element-wise (binary operator truediv).
dot(other) Matrix multiplication with DataFrame or inner-product with Series
drop(labels[, axis, level, inplace, errors]) Return new object with labels in requested axis removed.
drop_duplicates(*args, **kwargs) Return Series with duplicate values removed
dropna([axis, inplace]) Return Series without null values
dt alias of CombinedDatetimelikeProperties
duplicated(*args, **kwargs) Return boolean Series denoting duplicate values
eq(other[, axis])
equals(other) Determines if two NDFrame objects contain the same elements.
ewm([com, span, halflife, alpha, ...]) Provides exponential weighted functions
expanding([min_periods, freq, center, axis]) Provides expanding transformations.
factorize([sort, na_sentinel]) Encode the object as an enumerated type or categorical variable
ffill([axis, inplace, limit, downcast]) Synonym for NDFrame.fillna(method=’ffill’)
fillna([value, method, axis, inplace, ...]) Fill NA/NaN values using the specified method
filter([items, like, regex, axis]) Restrict the info axis to set of items or wildcard
first(offset) Convenience method for subsetting initial periods of time series data based on a date offset.
first_valid_index() Return label for first non-NA/null value
floordiv(other[, level, fill_value, axis]) Integer division of series and other, element-wise (binary operator floordiv).
from_array(arr[, index, name, dtype, copy, ...])
from_csv(path[, sep, parse_dates, header, ...]) Read CSV file (DISCOURAGED, please use pandas.read_csv() instead).
ge(other[, axis])
get(key[, default]) Get item from object for given key (DataFrame column, Panel slice, etc.).
get_dtype_counts() Return the counts of dtypes in this object.
get_ftype_counts() Return the counts of ftypes in this object.
get_value(label[, takeable]) Quickly retrieve single value at passed index label
get_values() same as values (but handles sparseness conversions); is a view
groupby([by, axis, level, as_index, sort, ...]) Group series using mapper (dict or key function, apply given function to group, return result as series) or by a series of columns.
gt(other[, axis])
head([n]) Returns first n rows
hist([by, ax, grid, xlabelsize, xrot, ...]) Draw histogram of the input series using matplotlib
idxmax([axis, skipna]) Index of first occurrence of maximum of values.
idxmin([axis, skipna]) Index of first occurrence of minimum of values.
iget(i[, axis]) DEPRECATED.
iget_value(i[, axis]) DEPRECATED.
interpolate([method, axis, limit, inplace, ...]) Interpolate values according to different methods.
irow(i[, axis]) DEPRECATED.
isin(values) Return a boolean Series showing whether each element in the Series is exactly contained in the passed sequence of values.
isnull() Return a boolean same-sized object indicating if the values are null.
item() return the first element of the underlying data as a python
iteritems() Lazily iterate over (index, value) tuples
iterkv(*args, **kwargs) iteritems alias used to get around 2to3. Deprecated
keys() Alias for index
kurt([axis, skipna, level, numeric_only]) Return unbiased kurtosis over requested axis using Fisher’s definition of kurtosis (kurtosis of normal == 0.0).
kurtosis([axis, skipna, level, numeric_only]) Return unbiased kurtosis over requested axis using Fisher’s definition of kurtosis (kurtosis of normal == 0.0).
last(offset) Convenience method for subsetting final periods of time series data based on a date offset.
last_valid_index() Return label for last non-NA/null value
le(other[, axis])
lt(other[, axis])
mad([axis, skipna, level]) Return the mean absolute deviation of the values for the requested axis
map(arg[, na_action]) Map values of Series using input correspondence (which can be
mask(cond[, other, inplace, axis, level, ...]) Return an object of same shape as self and whose corresponding entries are from self where cond is False and otherwise are from other.
max([axis, skipna, level, numeric_only]) This method returns the maximum of the values in the object.
mean([axis, skipna, level, numeric_only]) Return the mean of the values for the requested axis
median([axis, skipna, level, numeric_only]) Return the median of the values for the requested axis
memory_usage([index, deep]) Memory usage of the Series
min([axis, skipna, level, numeric_only]) This method returns the minimum of the values in the object.
mod(other[, level, fill_value, axis]) Modulo of series and other, element-wise (binary operator mod).
mode() Returns the mode(s) of the dataset.
mul(other[, level, fill_value, axis]) Multiplication of series and other, element-wise (binary operator mul).
multiply(other[, level, fill_value, axis]) Multiplication of series and other, element-wise (binary operator mul).
ne(other[, axis])
nlargest(*args, **kwargs) Return the largest n elements.
nonzero() Return the indices of the elements that are non-zero
notnull() Return a boolean same-sized object indicating if the values are not null.
nsmallest(*args, **kwargs) Return the smallest n elements.
nunique([dropna]) Return number of unique elements in the object.
order([na_last, ascending, kind, ...]) DEPRECATED: use Series.sort_values()
pct_change([periods, fill_method, limit, freq]) Percent change over given number of periods.
pipe(func, *args, **kwargs) Apply func(self, *args, **kwargs)
plot alias of SeriesPlotMethods
pop(item) Return item and drop from frame.
pow(other[, level, fill_value, axis]) Exponential power of series and other, element-wise (binary operator pow).
prod([axis, skipna, level, numeric_only]) Return the product of the values for the requested axis
product([axis, skipna, level, numeric_only]) Return the product of the values for the requested axis
ptp([axis, skipna, level, numeric_only]) Returns the difference between the maximum value and the minimum value in the object.
put(*args, **kwargs) Applies the put method to its values attribute if it has one.
quantile([q, interpolation]) Return value at the given quantile, a la numpy.percentile.
radd(other[, level, fill_value, axis]) 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]) Floating division of series and other, element-wise (binary operator rtruediv).
reindex([index]) Conform Series to new index with optional filling logic, placing NA/NaN in locations having no value in the previous index.
reindex_axis(labels[, axis]) for compatibility with higher dims
reindex_like(other[, method, copy, limit, ...]) Return an object with matching indices to myself.
rename([index]) Alter axes input function or functions.
rename_axis(mapper[, axis, copy, inplace]) Alter index and / or columns using input function or functions.
reorder_levels(order) Rearrange index levels using input order.
repeat(reps, *args, **kwargs) Repeat elements of an Series.
replace([to_replace, value, inplace, limit, ...]) Replace values given in ‘to_replace’ with ‘value’.
resample(rule[, how, axis, fill_method, ...]) Convenience method for frequency conversion and resampling of regular time-series data.
reset_index([level, drop, name, inplace]) Analogous to the pandas.DataFrame.reset_index() function, see docstring there.
reshape(*args, **kwargs) Return the values attribute of self with shape args.
rfloordiv(other[, level, fill_value, axis]) Integer division of series and other, element-wise (binary operator rfloordiv).
rmod(other[, level, fill_value, axis]) Modulo of series and other, element-wise (binary operator rmod).
rmul(other[, level, fill_value, axis]) Multiplication of series and other, element-wise (binary operator rmul).
rolling(window[, min_periods, freq, center, ...]) Provides rolling transformations.
round([decimals]) Round each value in a Series to the given number of decimals.
rpow(other[, level, fill_value, axis]) Exponential power of series and other, element-wise (binary operator rpow).
rsub(other[, level, fill_value, axis]) Subtraction of series and other, element-wise (binary operator rsub).
rtruediv(other[, level, fill_value, axis]) Floating division of series and other, element-wise (binary operator rtruediv).
sample([n, frac, replace, weights, ...]) Returns a random sample of items from an axis of object.
searchsorted(v[, side, sorter]) Find indices where elements should be inserted to maintain order.
select(crit[, axis]) Return data corresponding to axis labels matching criteria
sem([axis, skipna, level, ddof, numeric_only]) Return unbiased standard error of the mean over requested axis.
set_axis(axis, labels) public verson of axis assignment
set_value(label, value[, takeable]) Quickly set single value at passed label.
shift([periods, freq, axis]) 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]) Equivalent to shift without copying data.
sort([axis, ascending, kind, na_position, ...]) DEPRECATED: use Series.sort_values(inplace=True)() for INPLACE
sort_index([axis, level, ascending, ...]) Sort object by labels (along an axis)
sort_values([axis, ascending, inplace, ...]) Sort by the values along either axis
sortlevel([level, ascending, sort_remaining]) Sort Series with MultiIndex by chosen level.
squeeze(**kwargs) Squeeze length 1 dimensions.
std([axis, skipna, level, ddof, numeric_only]) Return sample standard deviation over requested axis.
str alias of StringMethods
sub(other[, level, fill_value, axis]) Subtraction of series and other, element-wise (binary operator sub).
subtract(other[, level, fill_value, axis]) Subtraction of series and other, element-wise (binary operator sub).
sum([axis, skipna, level, numeric_only]) Return the sum of the values for 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]) Returns last n rows
take(indices[, axis, convert, is_copy]) return Series corresponding to requested indices
to_clipboard([excel, sep]) Attempt to write text representation of object to the system clipboard This can be pasted into Excel, for example.
to_csv(path[, index, sep, na_rep, ...]) Write Series to a comma-separated values (csv) file
to_dense() Return dense representation of NDFrame (as opposed to sparse)
to_dict() Convert Series to {label -> value} dict
to_frame([name]) Convert Series to DataFrame
to_hdf(path_or_buf, key, **kwargs) Activate the HDFStore.
to_json([path_or_buf, orient, date_format, ...]) Convert the object to a JSON string.
to_msgpack([path_or_buf, encoding]) msgpack (serialize) object to input file path
to_period([freq, copy]) Convert Series from DatetimeIndex to PeriodIndex with desired
to_pickle(path) Pickle (serialize) object to input file path.
to_sparse([kind, fill_value]) Convert Series to SparseSeries
to_sql(name, con[, flavor, schema, ...]) 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() Convert Series to a nested list
transpose(*args, **kwargs) return the transpose, which is by definition self
truediv(other[, level, fill_value, axis]) Floating division of series and other, element-wise (binary operator truediv).
truncate([before, after, axis, copy]) Truncates a sorted NDFrame before and/or after some particular dates.
tshift([periods, freq, axis]) 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(*args, **kwargs) Localize tz-naive TimeSeries to target time zone.
unique() Return array of unique values in the object.
unstack([level, fill_value]) Unstack, a.k.a.
update(other) Modify Series in place using non-NA values from passed Series.
valid([inplace])
value_counts([normalize, sort, ascending, ...]) Returns object containing counts of unique values.
var([axis, skipna, level, ddof, numeric_only]) Return unbiased variance over requested axis.
view([dtype])
where(cond[, other, inplace, axis, level, ...]) Return an object of same shape as self and whose corresponding entries are from self where cond is True and otherwise are from other.
xs(key[, axis, level, copy, drop_level]) Returns a cross-section (row(s) or column(s)) from the Series/DataFrame.