class pandas.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 resulting index will be the sorted union of the two indexes. Parametersdataarray-like, Iterable, dict, or scalar value
Contains data stored in Series. If data is a dict, argument order is maintained.indexarray-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 values in the index are used to reindex the Series after it is created using the keys in the data.dtypestr, 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.namestr, optional
The name to give to the Series.copybool, default False
Copy input data.
Attributes
| S.N | Function | Meaning |
| 1 | T | Return the transpose, which is by definition self. |
| 2 | array | The ExtensionArray of the data backing this Series or Index. |
| 3 | at | Access a single value for a row/column label pair. |
| 4 | attrs | Dictionary of global attributes of this dataset. |
| 5 | axes | Return a list of the row axis labels. |
| 6 | dtype | Return the dtype object of the underlying data. |
| 7 | dtypes | Return the dtype object of the underlying data. |
| 8 | flags | Get the properties associated with this pandas object. |
| 9 | hasnans | Return if I have any nans; enables various perf speedups. |
| 10 | iat | Access a single value for a row/column pair by integer position. |
| 11 | iloc | Purely integer-location based indexing for selection by position. |
| 12 | index | The index (axis labels) of the Series. |
| 13 | is_monotonic | Return boolean if values in the object are monotonic_increasing. |
| 14 | is_monotonic_decreasing | Return boolean if values in the object are monotonic_decreasing. |
| 15 | is_monotonic_increasing | Alias for is_monotonic. |
| 16 | is_unique | Return boolean if values in the object are unique. |
| 17 | loc | Access a group of rows and columns by label(s) or a boolean array. |
| 18 | name | Return the name of the Series. |
| 19 | nbytes | Return the number of bytes in the underlying data. |
| 20 | ndim | Number of dimensions of the underlying data, by definition 1. |
| 21 | shape | Return a tuple of the shape of the underlying data. |
| 22 | size | Return the number of elements in the underlying data. |
| 23 | values | Return Series as ndarray or ndarray-like depending on the type. |
1. pandas.Series.T
Return the transpose, which is by definition self.
2. pandas.Series.array
The ExtensionArray of the data backing this Series or Index.ReturnsExtensionArray
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.
3. pandas.Series.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.RaisesKeyError
If ‘label’ does not exist in DataFrame.
4. pandas.Series.attrs
Dictionary of global attributes of this dataset.
5. pandas.Series.axes
Return a list of the row axis labels.
6.pandas.Series.dtype
Return the dtype object of the underlying data.
7.pandas.Series.dtypes
Return the dtype object of the underlying data.
8. pandas.Series.flags
Get the properties associated with this pandas object.
The available flags are
9. pandas.Series.hasnans
Return True if there are any NaNs.
Enables various performance speedups.
10. pandas.Series.iat
Access a single value for a row/column pair by integer position.
Similar to iloc, in that both provide integer-based lookups. Use iat if you only need to get or set a single value in a DataFrame or Series.RaisesIndexError
When integer position is out of bounds.
11. pandas.Series.iloc
Purely integer-location based indexing for selection by position.
.iloc[] is primarily integer position based (from 0 to length-1 of the axis), but may also be used with a boolean array.
Allowed inputs are:
- An integer, e.g.
5. - A list or array of integers, e.g.
[4, 3, 0]. - A slice object with ints, e.g.
1:7. - A boolean array.
- A
callablefunction with one argument (the calling Series or DataFrame) and that returns valid output for indexing (one of the above). This is useful in method chains, when you don’t have a reference to the calling object, but would like to base your selection on some value.
.iloc will raise IndexError if a requested indexer is out-of-bounds, except slice indexers which allow out-of-bounds indexing (this conforms with python/numpy slice semantics).
12. pandas.Series.index
The index (axis labels) of the Series.
13. pandas.Series.is_monotonic
Return boolean if values in the object are monotonic_increasing.Returns bool
14. pandas.Series.is_monotonic_decreasing
property Series.is_monotonic_decreasing
Return boolean if values in the object are monotonic_decreasing.Returns bool
15. pandas.Series.is_monotonic_increasing
property Series.is_monotonic_increasing
Alias for is_monotonic.
16. pandas.Series.is_unique
Return boolean if values in the object are unique.
Returns bool
17. pandas.Series.loc
Access a group of rows and columns by label(s) or a boolean array.
.loc[] is primarily label based, but may also be used with a boolean array.
Allowed inputs are:
- A single label, e.g.
5or'a', (note that5is interpreted as a label of the index, and never as an integer position along the index). - A list or array of labels, e.g.
['a', 'b', 'c']. - A slice object with labels, e.g.
'a':'f'.WarningNote that contrary to usual python slices, both the start and the stop are included - A boolean array of the same length as the axis being sliced, e.g.
[True, False, True]. - An alignable boolean Series. The index of the key will be aligned before masking.
- An alignable Index. The Index of the returned selection will be the input.
- A
callablefunction with one argument (the calling Series or DataFrame) and that returns valid output for indexing (one of the above)
See more at Selection by Label.RaisesKeyError
If any items are not found.IndexingError
If an indexed key is passed and its index is unalignable to the frame index.
18. pandas.Series.name
Return the name of the Series.
The name of a Series becomes its index or column name if it is used to form a DataFrame. It is also used whenever displaying the Series using the interpreter.Returnslabel (hashable object)
The name of the Series, also the column name if part of a DataFrame.
See alsoSeries.rename
Sets the Series name when given a scalar input.Index.name
Corresponding Index property.
Examples
The Series name can be set initially when calling the constructor.
>>> s = pd.Series([1, 2, 3], dtype=np.int64, name='Numbers') >>> s 0 1 1 2 2 3 Name: Numbers, dtype: int64 >>> s.name = "Integers" >>> s 0 1 1 2 2 3 Name: Integers, dtype: int64
The name of a Series within a DataFrame is its column name.
>>> df = pd.DataFrame([[1, 2], [3, 4], [5, 6]], ... columns=["Odd Numbers", "Even Numbers"]) >>> df Odd Numbers Even Numbers 0 1 2 1 3 4 2 5 6 >>> df["Even Numbers"].name 'Even Numbers'
19. pandas.Series.nbytes
Return the number of bytes in the underlying data.
20. pandas.Series.ndim
Number of dimensions of the underlying data, by definition 1.
21. pandas.Series.shape
Return a tuple of the shape of the underlying data.
22. pandas.Series.size
Return the number of elements in the underlying data.
23. pandas.Series.values
Return Series as ndarray or ndarray-like depending on the dtype.
Warning
We recommend using Series.array or Series.to_numpy(), depending on whether you need a reference to the underlying data or a NumPy array.Returnsnumpy.ndarray or ndarray-like
See alsoSeries.array
Reference to the underlying data.Series.to_numpy
A NumPy array representing the underlying data.
Examples
>>> pd.Series([1, 2, 3]).values array([1, 2, 3])
>>> pd.Series(list('aabc')).values
array(['a', 'a', 'b', 'c'], dtype=object)
>>> pd.Series(list('aabc')).astype('category').values
['a', 'a', 'b', 'c']
Categories (3, object): ['a', 'b', 'c']
Timezone aware datetime data is converted to UTC:
>>> pd.Series(pd.date_range('20130101', periods=3,
... tz='US/Eastern')).values
array(['2013-01-01T05:00:00.000000000',
'2013-01-02T05:00:00.000000000',
'2013-01-03T05:00:00.000000000'], dtype='datetime64[ns]')
Methods
| S.N | Method | Meaning |
| 1 | abs() | Return a Series/DataFrame with absolute numeric value of each element. |
| 2 | add(other[, level, fill_value, axis]) | Return Addition of series and other, element-wise (binary operator add). |
| 3 | add_prefix(prefix) | Prefix labels with string prefix. |
| 4 | add_suffix(suffix) | Suffix labels with string suffix. |
| 5 | agg([func, axis]) | Aggregate using one or more operations over the specified axis. |
| 6 | aggregate([func, axis]) | Aggregate using one or more operations over the specified axis. |
| 7 | align(other[, join, axis, level, copy, …]) | Align two objects on their axes with the specified join method. |
| 8 | all([axis, bool_only, skipna, level]) | Return whether all elements are True, potentially over an axis. |
| 9 | any([axis, bool_only, skipna, level]) | Return whether any element is True, potentially over an axis. |
| 10 | append(to_append[, ignore_index, …]) | Concatenate two or more Series. |
| 11 | apply(func[, convert_dtype, args]) | Invoke function on values of Series. |
| 12 | argmax([axis, skipna]) | Return int position of the largest value in the Series. |
| 13 | argmin([axis, skipna]) | Return int position of the smallest value in the Series. |
| 14 | argsort([axis, kind, order]) | Return the integer indices that would sort the Series values. |
| 15 | asfreq(freq[, method, how, normalize, …]) | Convert TimeSeries to specified frequency. |
| 16 | asof(where[, subset]) | Return the last row(s) without any NaNs before where. |
| 17 | astype(dtype[, copy, errors]) | Cast a pandas object to a specified dtype dtype. |
| 18 | at_time(time[, asof, axis]) | Select values at particular time of day (e.g., 9:30AM). |
| 19 | autocorr([lag]) | Compute the lag-N autocorrelation. |
| 20 | backfill([axis, inplace, limit, downcast]) | Synonym for DataFrame.fillna() with method='bfill'. |
| 21 | between(left, right[, inclusive]) | Return boolean Series equivalent to left <= series <= right. |
| 22 | between_time(start_time, end_time[, …]) | Select values between particular times of the day (e.g., 9:00-9:30 AM). |
| 23 | bfill([axis, inplace, limit, downcast]) | Synonym for DataFrame.fillna() with method='bfill'. |
| 24 | bool() | Return the bool of a single element Series or DataFrame. |
| 25 | cat | alias of pandas.core.arrays.categorical.CategoricalAccessor |
| 26 | clip([lower, upper, axis, inplace]) | Trim values at input threshold(s). |
| 27 | combine(other, func[, fill_value]) | Combine the Series with a Series or scalar according to func. |
| 28 | combine_first(other) | Combine Series values, choosing the calling Series’s values first. |
| 29 | compare(other[, align_axis, keep_shape, …]) | Compare to another Series and show the differences. |
| 30 | convert_dtypes([infer_objects, …]) | Convert columns to best possible dtypes using dtypes supporting pd.NA. |
| 31 | copy([deep]) | Make a copy of this object’s indices and data. |
| 32 | corr(other[, method, min_periods]) | Compute correlation with other Series, excluding missing values. |
| 33 | count([level]) | Return number of non-NA/null observations in the Series. |
| 34 | cov(other[, min_periods, ddof]) | Compute covariance with Series, excluding missing values. |
| 35 | cummax([axis, skipna]) | Return cumulative maximum over a DataFrame or Series axis. |
| 36 | cummin([axis, skipna]) | Return cumulative minimum over a DataFrame or Series axis. |
| 37 | cumprod([axis, skipna]) | Return cumulative product over a DataFrame or Series axis. |
| 38 | cumsum([axis, skipna]) | Return cumulative sum over a DataFrame or Series axis. |
| 39 | describe([percentiles, include, exclude, …]) | Generate descriptive statistics. |
| 40 | diff([periods]) | First discrete difference of element. |
| 41 | div(other[, level, fill_value, axis]) | Return Floating division of series and other, element-wise (binary operator truediv). |
| 42 | divide(other[, level, fill_value, axis]) | Return Floating division of series and other, element-wise (binary operator truediv). |
| 43 | divmod(other[, level, fill_value, axis]) | Return Integer division and modulo of series and other, element-wise (binary operator divmod). |
| 44 | dot(other) | Compute the dot product between the Series and the columns of other. |
| 45 | drop([labels, axis, index, columns, level, …]) | Return Series with specified index labels removed. |
| 46 | drop_duplicates([keep, inplace]) | Return Series with duplicate values removed. |
| 47 | droplevel(level[, axis]) | Return DataFrame with requested index / column level(s) removed. |
| 48 | dropna([axis, inplace, how]) | Return a new Series with missing values removed. |
| 49 | dt | alias of pandas.core.indexes.accessors.CombinedDatetimelikeProperties |
| 50 | duplicated([keep]) | Indicate duplicate Series values. |
| 51 | eq(other[, level, fill_value, axis]) | Return Equal to of series and other, element-wise (binary operator eq). |
| 52 | equals(other) | Test whether two objects contain the same elements. |
| 53 | ewm([com, span, halflife, alpha, …]) | Provide exponential weighted (EW) functions. |
| 54 | expanding([min_periods, center, axis]) | Provide expanding transformations. |
| 55 | explode([ignore_index]) | Transform each element of a list-like to a row. |
| 56 | factorize([sort, na_sentinel]) | Encode the object as an enumerated type or categorical variable. |
| 57 | ffill([axis, inplace, limit, downcast]) | Synonym for DataFrame.fillna() with method='ffill'. |
| 58 | fillna([value, method, axis, inplace, …]) | Fill NA/NaN values using the specified method. |
| 59 | filter([items, like, regex, axis]) | Subset the dataframe rows or columns according to the specified index labels. |
| 60 | first(offset) | Select initial periods of time series data based on a date offset. |
| 61 | first_valid_index() | Return index for first non-NA/null value. |
| 62 | floordiv(other[, level, fill_value, axis]) | Return Integer division of series and other, element-wise (binary operator floordiv). |
| 63 | ge(other[, level, fill_value, axis]) | Return Greater than or equal to of series and other, element-wise (binary operator ge). |
| 64 | get(key[, default]) | Get item from object for given key (ex: DataFrame column). |
| 65 | groupby([by, axis, level, as_index, sort, …]) | Group Series using a mapper or by a Series of columns. |
| 66 | gt(other[, level, fill_value, axis]) | Return Greater than of series and other, element-wise (binary operator gt). |
| 67 | head([n]) | Return the first n rows. |
| 68 | hist([by, ax, grid, xlabelsize, xrot, …]) | Draw histogram of the input series using matplotlib. |
| 69 | idxmax([axis, skipna]) | Return the row label of the maximum value. |
| 70 | idxmin([axis, skipna]) | Return the row label of the minimum value. |
| 71 | infer_objects() | Attempt to infer better dtypes for object columns. |
| 72 | interpolate([method, axis, limit, inplace, …]) | Fill NaN values using an interpolation method. |
| 73 | isin(values) | Whether elements in Series are contained in values. |
| 74 | isna() | Detect missing values. |
| 75 | isnull() | Detect missing values. |
| 76 | item() | Return the first element of the underlying data as a Python scalar. |
| 77 | items() | Lazily iterate over (index, value) tuples. |
| 78 | iteritems() | Lazily iterate over (index, value) tuples. |
| 79 | keys() | Return alias for index. |
| 80 | kurt([axis, skipna, level, numeric_only]) | Return unbiased kurtosis over requested axis. |
| 81 | kurtosis([axis, skipna, level, numeric_only]) | Return unbiased kurtosis over requested axis. |
| 82 | last(offset) | Select final periods of time series data based on a date offset. |
| 83 | last_valid_index() | Return index for last non-NA/null value. |
| 84 | le(other[, level, fill_value, axis]) | Return Less than or equal to of series and other, element-wise (binary operator le). |
| 85 | lt(other[, level, fill_value, axis]) | Return Less than of series and other, element-wise (binary operator lt). |
| 86 | mad([axis, skipna, level]) | Return the mean absolute deviation of the values over the requested axis. |
| 87 | map(arg[, na_action]) | Map values of Series according to input correspondence. |
| 88 | mask(cond[, other, inplace, axis, level, …]) | Replace values where the condition is True. |
| 89 | max([axis, skipna, level, numeric_only]) | Return the maximum of the values over the requested axis. |
| 90 | mean([axis, skipna, level, numeric_only]) | Return the mean of the values over the requested axis. |
| 91 | median([axis, skipna, level, numeric_only]) | Return the median of the values over the requested axis. |
| 92 | memory_usage([index, deep]) | Return the memory usage of the Series. |
| 93 | min([axis, skipna, level, numeric_only]) | Return the minimum of the values over the requested axis. |
| 94 | mod(other[, level, fill_value, axis]) | Return Modulo of series and other, element-wise (binary operator mod). |
| 95 | mode([dropna]) | Return the mode(s) of the Series. |
| 96 | mul(other[, level, fill_value, axis]) | Return Multiplication of series and other, element-wise (binary operator mul). |
| 97 | multiply(other[, level, fill_value, axis]) | Return Multiplication of series and other, element-wise (binary operator mul). |
| 98 | ne(other[, level, fill_value, axis]) | Return Not equal to of series and other, element-wise (binary operator ne). |
| 99 | nlargest([n, keep]) | Return the largest n elements. |
| 100 | notna() | Detect existing (non-missing) values. |
| 101 | notnull() | Detect existing (non-missing) values. |
| 102 | nsmallest([n, keep]) | Return the smallest n elements. |
| 103 | nunique([dropna]) | Return number of unique elements in the object. |
| 104 | pad([axis, inplace, limit, downcast]) | Synonym for DataFrame.fillna() with method='ffill'. |
| 105 | pct_change([periods, fill_method, limit, freq]) | Percentage change between the current and a prior element. |
| 106 | pipe(func, *args, **kwargs) | Apply func(self, *args, **kwargs). |
| 107 | plot | alias of pandas.plotting._core.PlotAccessor |
| 108 | pop(item) | Return item and drops from series. |
| 109 | pow(other[, level, fill_value, axis]) | Return Exponential power of series and other, element-wise (binary operator pow). |
| 110 | prod([axis, skipna, level, numeric_only, …]) | Return the product of the values over the requested axis. |
| 111 | product([axis, skipna, level, numeric_only, …]) | Return the product of the values over the requested axis. |
| 112 | quantile([q, interpolation]) | Return value at the given quantile. |
| 113 | radd(other[, level, fill_value, axis]) | Return Addition of series and other, element-wise (binary operator radd). |
| 114 | rank([axis, method, numeric_only, …]) | Compute numerical data ranks (1 through n) along axis. |
| 115 | ravel([order]) | Return the flattened underlying data as an ndarray. |
| 116 | rdiv(other[, level, fill_value, axis]) | Return Floating division of series and other, element-wise (binary operator rtruediv). |
| 117 | rdivmod(other[, level, fill_value, axis]) | Return Integer division and modulo of series and other, element-wise (binary operator rdivmod). |
| 118 | reindex([index]) | Conform Series to new index with optional filling logic. |
| 119 | reindex_like(other[, method, copy, limit, …]) | Return an object with matching indices as other object. |
| 120 | rename([index, axis, copy, inplace, level, …]) | Alter Series index labels or name. |
| 121 | rename_axis([mapper, index, columns, axis, …]) | Set the name of the axis for the index or columns. |
| 122 | reorder_levels(order) | Rearrange index levels using input order. |
| 123 | repeat(repeats[, axis]) | Repeat elements of a Series. |
| 124 | replace([to_replace, value, inplace, limit, …]) | Replace values given in to_replace with value. |
| 125 | resample(rule[, axis, closed, label, …]) | Resample time-series data. |
| 126 | reset_index([level, drop, name, inplace]) | Generate a new DataFrame or Series with the index reset. |
| 127 | rfloordiv(other[, level, fill_value, axis]) | Return Integer division of series and other, element-wise (binary operator rfloordiv). |
| 128 | rmod(other[, level, fill_value, axis]) | Return Modulo of series and other, element-wise (binary operator rmod). |
| 129 | rmul(other[, level, fill_value, axis]) | Return Multiplication of series and other, element-wise (binary operator rmul). |
| 130 | rolling(window[, min_periods, center, …]) | Provide rolling window calculations. |
| 131 | round([decimals]) | Round each value in a Series to the given number of decimals. |
| 132 | rpow(other[, level, fill_value, axis]) | Return Exponential power of series and other, element-wise (binary operator rpow). |
| 133 | rsub(other[, level, fill_value, axis]) | Return Subtraction of series and other, element-wise (binary operator rsub). |
| 134 | rtruediv(other[, level, fill_value, axis]) | Return Floating division of series and other, element-wise (binary operator rtruediv). |
| 135 | sample([n, frac, replace, weights, …]) | Return a random sample of items from an axis of object. |
| 136 | searchsorted(value[, side, sorter]) | Find indices where elements should be inserted to maintain order. |
| 137 | sem([axis, skipna, level, ddof, numeric_only]) | Return unbiased standard error of the mean over requested axis. |
| 138 | set_axis(labels[, axis, inplace]) | Assign desired index to given axis. |
| 139 | set_flags(*[, copy, allows_duplicate_labels]) | Return a new object with updated flags. |
| 140 | shift([periods, freq, axis, fill_value]) | Shift index by desired number of periods with an optional time freq. |
| 141 | skew([axis, skipna, level, numeric_only]) | Return unbiased skew over requested axis. |
| 142 | slice_shift([periods, axis]) | (DEPRECATED) Equivalent to shift without copying data. |
| 143 | sort_index([axis, level, ascending, …]) | Sort Series by index labels. |
| 144 | sort_values([axis, ascending, inplace, …]) | Sort by the values. |
| 145 | sparse | alias of pandas.core.arrays.sparse.accessor.SparseAccessor |
| 146 | squeeze([axis]) | Squeeze 1 dimensional axis objects into scalars. |
| 147 | std([axis, skipna, level, ddof, numeric_only]) | Return sample standard deviation over requested axis. |
| 148 | str | alias of pandas.core.strings.accessor.StringMethods |
| 149 | sub(other[, level, fill_value, axis]) | Return Subtraction of series and other, element-wise (binary operator sub). |
| 150 | subtract(other[, level, fill_value, axis]) | Return Subtraction of series and other, element-wise (binary operator sub). |
| 151 | sum([axis, skipna, level, numeric_only, …]) | Return the sum of the values over the requested axis. |
| 152 | swapaxes(axis1, axis2[, copy]) | Interchange axes and swap values axes appropriately. |
| 153 | swaplevel([i, j, copy]) | Swap levels i and j in a MultiIndex. |
| 154 | tail([n]) | Return the last n rows. |
| 155 | take(indices[, axis, is_copy]) | Return the elements in the given positional indices along an axis. |
| 156 | to_clipboard([excel, sep]) | Copy object to the system clipboard. |
| 157 | to_csv([path_or_buf, sep, na_rep, …]) | Write object to a comma-separated values (csv) file. |
| 158 | to_dict([into]) | Convert Series to {label -> value} dict or dict-like object. |
| 159 | to_excel(excel_writer[, sheet_name, na_rep, …]) | Write object to an Excel sheet. |
| 160 | to_frame([name]) | Convert Series to DataFrame. |
| 161 | to_hdf(path_or_buf, key[, mode, complevel, …]) | Write the contained data to an HDF5 file using HDFStore. |
| 162 | to_json([path_or_buf, orient, date_format, …]) | Convert the object to a JSON string. |
| 163 | to_latex([buf, columns, col_space, header, …]) | Render object to a LaTeX tabular, longtable, or nested table/tabular. |
| 164 | to_list() | Return a list of the values. |
| 165 | to_markdown([buf, mode, index, storage_options]) | Print Series in Markdown-friendly format. |
| 166 | to_numpy([dtype, copy, na_value]) | A NumPy ndarray representing the values in this Series or Index. |
| 167 | to_period([freq, copy]) | Convert Series from DatetimeIndex to PeriodIndex. |
| 168 | to_pickle(path[, compression, protocol, …]) | Pickle (serialize) object to file. |
| 169 | to_sql(name, con[, schema, if_exists, …]) | Write records stored in a DataFrame to a SQL database. |
| 170 | to_string([buf, na_rep, float_format, …]) | Render a string representation of the Series. |
| 171 | to_timestamp([freq, how, copy]) | Cast to DatetimeIndex of Timestamps, at beginning of period. |
| 172 | to_xarray() | Return an xarray object from the pandas object. |
| 173 | tolist() | Return a list of the values. |
| 174 | transform(func[, axis]) | Call func on self producing a Series with transformed values. |
| 175 | transpose(*args, **kwargs) | Return the transpose, which is by definition self. |
| 176 | truediv(other[, level, fill_value, axis]) | Return Floating division of series and other, element-wise (binary operator truediv). |
| 177 | truncate([before, after, axis, copy]) | Truncate a Series or DataFrame before and after some index value. |
| 178 | tshift([periods, freq, axis]) | (DEPRECATED) Shift the time index, using the index’s frequency if available. |
| 179 | tz_convert(tz[, axis, level, copy]) | Convert tz-aware axis to target time zone. |
| 180 | tz_localize(tz[, axis, level, copy, …]) | Localize tz-naive index of a Series or DataFrame to target time zone. |
| 181 | unique() | Return unique values of Series object. |
| 182 | unstack([level, fill_value]) | Unstack, also known as pivot, Series with MultiIndex to produce DataFrame. |
| 183 | update(other) | Modify Series in place using values from passed Series. |
| 184 | value_counts([normalize, sort, ascending, …]) | Return a Series containing counts of unique values. |
| 185 | var([axis, skipna, level, ddof, numeric_only]) | Return unbiased variance over requested axis. |
| 186 | view([dtype]) | Create a new view of the Series. |
| 187 | where(cond[, other, inplace, axis, level, …]) | Replace values where the condition is False. |
| 188 | xs(key[, axis, level, drop_level]) | Return cross-section from the Series/DataFrame. |
1.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.ParametersotherSeries or scalar valuefill_valueNone 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.levelint or name
Broadcast across a level, matching Index values on the passed MultiIndex level.ReturnsSeries
The result of the operation.
See alsoSeries.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
2.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.ParametersotherSeries or scalar valuefill_valueNone 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.levelint or name
Broadcast across a level, matching Index values on the passed MultiIndex level.ReturnsSeries
The result of the operation.
See alsoSeries.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
3.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.Parametersprefixstr
The string to add before each label.ReturnsSeries or DataFrame
New Series or DataFrame with updated labels.
See alsoSeries.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
4.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.Parameterssuffixstr
The string to add after each label.ReturnsSeries or DataFrame
New Series or DataFrame with updated labels.
See alsoSeries.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