# Series¶

## 构造函数¶

 Series([data, index, dtype, name, copy, …])

## 属性¶

 Series.index The index (axis labels) of the Series.
 Series.dtype Return the dtype object of the underlying data. Series.shape Series.ndim Return an int representing the number of axes / array dimensions. Series.name Series.memory_usage([index, deep]) Return the memory usage of the Series.

## 转换¶

 Series.astype(dtype[, copy, errors]) Cast a pandas object to a specified dtype dtype. Series.copy([deep]) Make a copy of this object’s indices and data. Series.to_frame([name]) Convert Series to DataFrame. Series.to_tensor([dtype])

## 索引和迭代¶

 Series.at Access a single value for a row/column label pair. Series.iat Series.loc Series.iloc Series.items([batch_size, session]) Lazily iterate over (index, value) tuples. Series.iteritems([batch_size, session]) Lazily iterate over (index, value) tuples. Series.mask(cond[, other, inplace, axis, …]) Replace values where the condition is True. Series.where(cond[, other, inplace, axis, …]) Replace values where the condition is False.

## 二元运算函数¶

 Series.add(other[, level, fill_value, axis]) Return Addition of series and other, element-wise (binary operator add). Series.sub(other[, level, fill_value, axis]) Return Subtraction of series and other, element-wise (binary operator subtract). Series.mul(other[, level, fill_value, axis]) Return Multiplication of series and other, element-wise (binary operator mul). Series.div(other[, level, fill_value, axis]) Return Floating division of series and other, element-wise (binary operator truediv). Series.truediv(other[, level, fill_value, axis]) Return Floating division of series and other, element-wise (binary operator truediv). Series.floordiv(other[, level, fill_value, axis]) Return Integer division of series and other, element-wise (binary operator floordiv). Series.mod(other[, level, fill_value, axis]) Return Modulo of series and other, element-wise (binary operator mod). Series.pow(other[, level, fill_value, axis]) Return Exponential power of series and other, element-wise (binary operator pow). Series.radd(other[, level, fill_value, axis]) Return Addition of series and other, element-wise (binary operator radd). Series.rsub(other[, level, fill_value, axis]) Return Subtraction of series and other, element-wise (binary operator rsubtract). Series.rmul(other[, level, fill_value, axis]) Return Multiplication of series and other, element-wise (binary operator rmul). Series.rdiv(other[, level, fill_value, axis]) Return Floating division of series and other, element-wise (binary operator rtruediv). Series.rtruediv(other[, level, fill_value, axis]) Return Floating division of series and other, element-wise (binary operator rtruediv). Series.rfloordiv(other[, level, fill_value, …]) Return Integer division of series and other, element-wise (binary operator rfloordiv). Series.rmod(other[, level, fill_value, axis]) Return Modulo of series and other, element-wise (binary operator rmod). Series.rpow(other[, level, fill_value, axis]) Return Exponential power of series and other, element-wise (binary operator rpow). Series.lt(other[, level, axis]) Return Less than of series and other, element-wise (binary operator lt). Series.gt(other[, level, axis]) Return Greater than of series and other, element-wise (binary operator gt). Series.le(other[, level, axis]) Return Less than or equal to of series and other, element-wise (binary operator le). Series.ge(other[, level, axis]) Return Greater than or equal to of series and other, element-wise (binary operator ge). Series.ne(other[, level, axis]) Return Not equal to of series and other, element-wise (binary operator ne). Series.eq(other[, level, axis]) Return Equal to of series and other, element-wise (binary operator eq). Series.dot(other) Compute the dot product between the Series and the columns of other.

## 应用函数、分组和窗口¶

 Series.apply(func[, convert_dtype, …]) Invoke function on values of Series. Series.agg([func, axis]) Series.aggregate([func, axis]) Series.transform(func[, convert_dtype, …]) Call func on self producing a Series with transformed values. Series.map(arg[, na_action, dtype, memory_scale]) Map values of Series according to input correspondence. Series.groupby([by, level, as_index, sort, …]) Series.rolling(window[, min_periods, …]) Provide rolling window calculations. Series.expanding([min_periods, center, axis]) Provide expanding transformations. Series.ewm([com, span, halflife, alpha, …]) Provide exponential weighted functions.

## 计算和描述统计¶

 Series.all([axis, bool_only, skipna, level, …]) Series.any([axis, bool_only, skipna, level, …]) Series.autocorr([lag]) Compute the lag-N autocorrelation. Series.corr(other[, method, min_periods]) Compute correlation with other Series, excluding missing values. Series.count([level, combine_size]) Series.cummax([axis, skipna]) Series.cummin([axis, skipna]) Series.cumprod([axis, skipna]) Series.cumsum([axis, skipna]) Series.describe([percentiles, include, exclude]) Series.is_monotonic Return boolean scalar if values in the object are monotonic_increasing. Series.is_monotonic_decreasing Return boolean scalar if values in the object are monotonic_decreasing. Series.is_monotonic_increasing Return boolean scalar if values in the object are monotonic_increasing. Series.kurt([axis, skipna, level, …]) Series.kurtosis([axis, skipna, level, …]) Series.max([axis, skipna, level, combine_size]) Series.mean([axis, skipna, level, combine_size]) Series.min([axis, skipna, level, combine_size]) Series.pct_change([periods, fill_method, …]) Percentage change between the current and a prior element. Series.prod([axis, skipna, level, …]) Series.product([axis, skipna, level, …]) Series.quantile([q, interpolation]) Return value at the given quantile. Series.round([decimals]) Round each value in a Series to the given number of decimals. Series.sem([axis, skipna, level, ddof, …]) Series.skew([axis, skipna, level, …]) Series.std([axis, skipna, level, ddof, …]) Series.sum([axis, skipna, level, min_count, …]) Series.var([axis, skipna, level, ddof, …]) Series.nunique([dropna, combine_size]) Return number of unique elements in the object. Series.value_counts([normalize, sort, …]) Return a Series containing counts of unique values.

## 重设索引、选择和标签操作¶

 Series.drop([labels, axis, index, columns, …]) Return Series with specified index labels removed. Series.drop_duplicates([keep, inplace, method]) Return Series with duplicate values removed. Series.duplicated([keep, method]) Indicate duplicate Series values. Series.head([n]) Return the first n rows. Series.isin(values) Whether elements in Series are contained in values. Series.reindex(*args, **kwargs) Conform Series/DataFrame to new index with optional filling logic. Series.reindex_like(other[, method, copy, …]) Return an object with matching indices as other object. Series.rename([index, axis, copy, inplace, …]) Alter Series index labels or name. Series.rename_axis([mapper, index, columns, …]) Set the name of the axis for the index or columns. Series.reset_index([level, drop, name, …]) Generate a new DataFrame or Series with the index reset. Series.sample([n, frac, replace, weights, …]) Return a random sample of items from an axis of object. Series.set_axis(labels[, axis, inplace]) Assign desired index to given axis. Series.tail([n]) Return the last n rows.

## 缺失值处理¶

 Detect missing values. Detect existing (non-missing) values. Series.dropna([axis, inplace, how]) Return a new Series with missing values removed. Series.fillna([value, method, axis, …]) Fill NA/NaN values using the specified method.

## 形状变换和排序¶

 Series.explode([ignore_index]) Transform each element of a list-like to a row. Series.sort_values([axis, ascending, …]) Sort by the values. Series.sort_index([axis, level, ascending, …]) Sort object by labels (along an axis).

## 数据合并¶

 Series.append(other[, ignore_index, …])

## 类型访问器¶

Pandas 提供了针对不同数据类型的访问器。下面列出了 Series 下只针对特定类型的独立名称空间。

dt

str

### 日期时间类属性¶

Series.dt 可被用于访问日期时间类型的 Series，返回若干个属性值。这些属性值可通过 Series.dt.<property> 来调用。

#### 日期时间属性¶

 Series.dt.date Returns numpy array of python datetime.date objects (namely, the date part of Timestamps without timezone information). Series.dt.time Returns numpy array of datetime.time. Series.dt.timetz Returns numpy array of datetime.time also containing timezone information. Series.dt.year The year of the datetime. Series.dt.month The month as January=1, December=12. Series.dt.day The day of the datetime. Series.dt.hour The hours of the datetime. Series.dt.minute The minutes of the datetime. Series.dt.second The seconds of the datetime. Series.dt.microsecond The microseconds of the datetime. Series.dt.nanosecond The nanoseconds of the datetime. Series.dt.week The week ordinal of the year. Series.dt.weekofyear The week ordinal of the year. Series.dt.dayofweek The day of the week with Monday=0, Sunday=6. Series.dt.weekday The day of the week with Monday=0, Sunday=6. Series.dt.dayofyear The ordinal day of the year. Series.dt.quarter The quarter of the date. Series.dt.is_month_start Indicates whether the date is the first day of the month. Series.dt.is_month_end Indicates whether the date is the last day of the month. Series.dt.is_quarter_start Indicator for whether the date is the first day of a quarter. Series.dt.is_quarter_end Indicator for whether the date is the last day of a quarter. Series.dt.is_year_start Indicate whether the date is the first day of a year. Series.dt.is_year_end Indicate whether the date is the last day of the year. Series.dt.is_leap_year Boolean indicator if the date belongs to a leap year. Series.dt.daysinmonth The number of days in the month. Series.dt.days_in_month The number of days in the month. Series.dt.tz Return timezone, if any. Series.dt.freq

#### 日期时间方法¶

 Series.dt.to_period(*args, **kwargs) Cast to PeriodArray/Index at a particular frequency. Return the data as an array of native Python datetime objects. Series.dt.tz_localize(*args, **kwargs) Localize tz-naive Datetime Array/Index to tz-aware Datetime Array/Index. Series.dt.tz_convert(*args, **kwargs) Convert tz-aware Datetime Array/Index from one time zone to another. Series.dt.normalize(*args, **kwargs) Convert times to midnight. Series.dt.strftime(*args, **kwargs) Convert to Index using specified date_format. Series.dt.round(*args, **kwargs) Perform round operation on the data to the specified freq. Series.dt.floor(*args, **kwargs) Perform floor operation on the data to the specified freq. Series.dt.ceil(*args, **kwargs) Perform ceil operation on the data to the specified freq. Series.dt.month_name(*args, **kwargs) Return the month names of the DateTimeIndex with specified locale. Series.dt.day_name(*args, **kwargs) Return the day names of the DateTimeIndex with specified locale.

#### 时间差属性¶

 Series.dt.days Number of days for each element. Series.dt.seconds Number of seconds (>= 0 and less than 1 day) for each element. Series.dt.microseconds Number of microseconds (>= 0 and less than 1 second) for each element. Series.dt.nanoseconds Number of nanoseconds (>= 0 and less than 1 microsecond) for each element. Series.dt.components Return a Dataframe of the components of the Timedeltas.

#### 时间差方法¶

 Return an array of native datetime.timedelta objects. Series.dt.total_seconds(*args, **kwargs) Return total duration of each element expressed in seconds.

### 处理字符串¶

Series.str 可被用于以字符串方式访问 Series，并应用若干方法。这些功能可通过 Series.str.<function/property> 来调用。

 Convert strings in the Series/Index to be casefolded. Series.str.cat([others, sep, na_rep, join]) Concatenate strings in the Series/Index with given separator. Series.str.center(width[, fillchar]) Pad left and right side of strings in the Series/Index. Series.str.contains(pat[, case, flags, na, …]) Test if pattern or regex is contained within a string of a Series or Index. Series.str.count(pat[, flags]) Count occurrences of pattern in each string of the Series/Index. Series.str.decode(encoding[, errors]) Decode character string in the Series/Index using indicated encoding. Series.str.encode(encoding[, errors]) Encode character string in the Series/Index using indicated encoding. Series.str.endswith(pat[, na]) Test if the end of each string element matches a pattern. Series.str.extract(pat[, flags, expand]) Extract capture groups in the regex pat as columns in a DataFrame. Series.str.extractall(pat[, flags]) Extract capture groups in the regex pat as columns in DataFrame. Series.str.find(sub[, start, end]) Return lowest indexes in each strings in the Series/Index. Series.str.findall(pat[, flags]) Find all occurrences of pattern or regular expression in the Series/Index. Extract element from each component at specified position. Series.str.index(sub[, start, end]) Return lowest indexes in each string in Series/Index. Series.str.join(sep) Join lists contained as elements in the Series/Index with passed delimiter. Compute the length of each element in the Series/Index. Series.str.ljust(width[, fillchar]) Pad right side of strings in the Series/Index. Convert strings in the Series/Index to lowercase. Series.str.lstrip([to_strip]) Remove leading characters. Series.str.match(pat[, case, flags, na]) Determine if each string starts with a match of a regular expression. Series.str.normalize(form) Return the Unicode normal form for the strings in the Series/Index. Series.str.pad(width[, side, fillchar]) Pad strings in the Series/Index up to width. Series.str.partition([sep, expand]) Split the string at the first occurrence of sep. Series.str.repeat(repeats) Duplicate each string in the Series or Index. Series.str.replace(pat, repl[, n, case, …]) Replace each occurrence of pattern/regex in the Series/Index. Series.str.rfind(sub[, start, end]) Return highest indexes in each strings in the Series/Index. Series.str.rindex(sub[, start, end]) Return highest indexes in each string in Series/Index. Series.str.rjust(width[, fillchar]) Pad left side of strings in the Series/Index. Series.str.rpartition([sep, expand]) Split the string at the last occurrence of sep. Series.str.rstrip([to_strip]) Remove trailing characters. Series.str.slice([start, stop, step]) Slice substrings from each element in the Series or Index. Series.str.slice_replace([start, stop, repl]) Replace a positional slice of a string with another value. Series.str.split([pat, n, expand]) Split strings around given separator/delimiter. Series.str.rsplit([pat, n, expand]) Split strings around given separator/delimiter. Series.str.startswith(pat[, na]) Test if the start of each string element matches a pattern. Series.str.strip([to_strip]) Remove leading and trailing characters. Convert strings in the Series/Index to be swapcased. Convert strings in the Series/Index to titlecase. Series.str.translate(table) Map all characters in the string through the given mapping table. Convert strings in the Series/Index to uppercase. Series.str.wrap(width, **kwargs) Wrap strings in Series/Index at specified line width. Series.str.zfill(width) Pad strings in the Series/Index by prepending ‘0’ characters. Check whether all characters in each string are alphanumeric. Check whether all characters in each string are alphabetic. Check whether all characters in each string are digits. Check whether all characters in each string are alphanumeric. Check whether all characters in each string are lowercase. Check whether all characters in each string are uppercase. Check whether all characters in each string are titlecase. Check whether all characters in each string are numeric. Check whether all characters in each string are decimal.

## 绘图¶

Series.plot 既是一个可被调用的方法，也是一个通过 Series.plot.<kind> 提供特定画图方法的属性。

 Series.plot alias of mars.dataframe.plotting.core.PlotAccessor
 Series.plot.area(*args, **kwargs) Draw a stacked area plot. Series.plot.bar(*args, **kwargs) Vertical bar plot. Series.plot.barh(*args, **kwargs) Make a horizontal bar plot. Series.plot.box(*args, **kwargs) Make a box plot of the DataFrame columns. Series.plot.density(*args, **kwargs) Generate Kernel Density Estimate plot using Gaussian kernels. Series.plot.hist(*args, **kwargs) Draw one histogram of the DataFrame’s columns. Series.plot.kde(*args, **kwargs) Generate Kernel Density Estimate plot using Gaussian kernels. Series.plot.line(*args, **kwargs) Plot Series or DataFrame as lines. Series.plot.pie(*args, **kwargs) Generate a pie plot.

### 序列化、IO 和转换¶

 Series.to_csv(path[, sep, na_rep, …]) Write object to a comma-separated values (csv) file. Series.to_sql(name, con[, schema, …]) Write records stored in a DataFrame to a SQL database.

### Misc¶

 Series.map_chunk(func[, args]) Apply function to each chunk.