Pandas API 文档索引中文翻译版(一)—— Series

说明:以Pandas官方API文档https://pandas.pydata.org/docs/reference/index.html为依据,根据使用频率对次序稍作整理,翻译API功能,计划补充API详细解读。

当前版本:1.3.4

Series

Constructor:构造函数

API功能解读
Series([data, index, dtype, name, copy, …])构造带轴标签的一维ndarry数组。

Attributes:属性

Axes

API功能解读
Series.indexSeries的索引(轴标签)。
Series.array返回以数组形式(ndarray的简易包装)返回Series的基础数据。
Series.values根据dtype返以数组或类数组形式返回Series数组。
Series.dtype返回基础数据的dtype对象。
Series.shape以元组形式返回基础数据的形状(shape)。
Series.nbytes返回基础数据的字节数。(相当于memory_usage(index=False))
Series.ndim返回基础数据的维数。
Series.size返回基础数据的元素个数。
Series.T返回Series的转置。
Series.memory_usage([index, deep])返回Series的内存使用量。(可设置不包含索引的使用量)
Series.hasnans返回Series是否有空值(nans),启用各种性能加速。
Series.empty标识Series是否为空。
Series.dtypes返回基础数据的dtype对象。
Series.name返回Series的名称。
Series.flags获取与Series对象相关联的属性。
Series.set_flags(*[, copy, …])返回更新属性后的Series对象。

Conversion:转换

API功能解读
Series.astype(dtype[, copy, errors])dtype格式对Series对象进行转换。
Series.convert_dtypes([infer_objects, …])使用支持 pd.NA的dtypes转换列。
Series.infer_objects()尝试为Series对象列推断更好的数据类型。
Series.copy([deep])创建一个Series对象的索引和数据的拷贝。
Series.bool()Return the bool of a single element Series or DataFrame.
Series.to_numpy([dtype, copy, na_value])以ndarray的形式返回Series 对象或 Index对象的值。
Series.to_period([freq, copy])将Series 格式从DatetimeIndex转换为PeriodIndex。
Series.to_timestamp([freq, how, copy])Cast to DatetimeIndex of Timestamps, at beginning of period.
Series.to_list()以列表形式返回Series值。
Series.__array__([dtype])Return the values as a NumPy array.

Indexing, iteration:索引,迭代

API功能解读
Series.at根据行/列标签对获取单独的一个值。
Series.iat根据整数位置对获取单独的一个值。
Series.loc根据标签获取一个行/列组或者布尔数组。
Series.iloc根据整数位置索引数据。
Series.__iter__()返回一个Series.values属性的迭代器。
Series.items()返回一个(index, value)元组形式的惰性迭代器。
Series.iteritems()返回一个(index, value)元组形式的惰性迭代器。
Series.get(key[, default])根据给定的键获取对象的元素,如果未找到键,返回默认值。
Series.keys()返回索引的别名。
Series.pop(item)根据标签弹出项,并返回弹出项。
Series.item()以Python标量形式返回Series基础数据的第一个元素。(已废弃)
Series.xs(key[, axis, level, drop_level])Return cross-section from the Series/DataFrame.

For more information on .at, .iat, .loc, and .iloc, see the indexing documentation.

Binary operator functions:二元操作符函数

API功能解读
Series.add(other[, level, fill_value, axis])返回Series和其他对象逐元素相加的总和(二元运算符+)。
Series.sub(other[, level, fill_value, axis])返回Series和其他对象逐元素相减的差值(二元运算符-)。
Series.mul(other[, level, fill_value, axis])返回Series和其他对象逐元素相乘的乘积(二元运算符*)。
Series.div(other[, level, fill_value, axis])返回Series和其他对象逐元素进行浮点数相除的商(二元运算符真除法/)。
Series.truediv(other[, level, fill_value, axis])返回Series和其他对象逐元素进行浮点数相除的商(二元运算符真除法/)。
Series.floordiv(other[, level, fill_value, axis])返回Series和其他对象逐元素进行整数相除的商(二元运算符floor除法//)。
Series.mod(other[, level, fill_value, axis])逐元素返回Series和其他对象的模(二元运算符 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 rsub).
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.combine(other, func[, fill_value])Combine the Series with a Series or scalar according to func.
Series.combine_first(other)Update null elements with value in the same location in ‘other’.
Series.round([decimals])Round each value in a Series to the given number of decimals.
Series.lt(other[, level, fill_value, axis])Return Less than of series and other, element-wise (binary operator lt).
Series.gt(other[, level, fill_value, axis])Return Greater than of series and other, element-wise (binary operator gt).
Series.le(other[, level, fill_value, axis])Return Less than or equal to of series and other, element-wise (binary operator le).
Series.ge(other[, level, fill_value, axis])Return Greater than or equal to of series and other, element-wise (binary operator ge).
Series.ne(other[, level, fill_value, axis])Return Not equal to of series and other, element-wise (binary operator ne).
Series.eq(other[, level, fill_value, axis])Return Equal to of series and other, element-wise (binary operator eq).
Series.product([axis, skipna, level, …])返回请求轴上所有值的乘积。
Series.dot(other)计算Series和其他对象的列的点乘。

Function application, GroupBy & window:应用函数、分组和窗口

API功能解读
Series.apply(func[, convert_dtype, args])Invoke function on values of Series.
Series.agg([func, axis])Aggregate using one or more operations over the specified axis.
Series.aggregate([func, axis])Aggregate using one or more operations over the specified axis.
Series.transform(func[, axis])Call func on self producing a Series with transformed values.
Series.map(arg[, na_action])Map values of Series according to input correspondence.
Series.groupby([by, axis, level, as_index, …])Group Series using a mapper or by a Series of columns.
Series.rolling(window[, min_periods, …])Provide rolling window calculations.
Series.expanding([min_periods, center, …])Provide expanding transformations.
Series.ewm([com, span, halflife, alpha, …])Provide exponential weighted (EW) functions.
Series.pipe(func, *args, **kwargs)Apply func(self, *args, **kwargs).

Computations / descriptive stats:计算,描述性统计

API功能解读
Series.abs()返回每个元素的绝对值构成的Series。
Series.all([axis, bool_only, skipna, level])Return whether all elements are True, potentially over an axis.
Series.any([axis, bool_only, skipna, level])Return whether any element is True, potentially over an axis.
Series.autocorr([lag])计算 lag-N 自相关系数。
Series.between(left, right[, inclusive])返回表达式left <= series <= right的布尔Series。
Series.clip([lower, upper, axis, inplace])根据输入阈值修整数据。
Series.corr(other[, method, min_periods])在排除缺失值的情况下,计算Series与其他Series的相关系数。
Series.count([level])返回Series中非空值的个数。
Series.cov(other[, min_periods, ddof])在排除缺失值的情况下,计算Series与其他Series的协方差。
Series.cummax([axis, skipna])返回Series轴上的累积最大值。
Series.cummin([axis, skipna])返回Series轴上的累积最小值。
Series.cumprod([axis, skipna])返回Series轴上的累积乘积。
Series.cumsum([axis, skipna])返回Series轴上的累积总和。
Series.describe([percentiles, include, …])生成描述性统计值。
Series.diff([periods])元素的离散差分的第一个解。
Series.factorize([sort, na_sentinel])Encode the object as an enumerated type or categorical variable.
Series.kurt([axis, skipna, level, numeric_only])Return unbiased kurtosis over requested axis.
Series.mad([axis, skipna, level])Return the mean absolute deviation of the values over the requested axis.
Series.max([axis, skipna, level, numeric_only])返回请求轴上值的最大值。
Series.mean([axis, skipna, level, numeric_only])返回请求轴上值的均值。
Series.median([axis, skipna, level, …])返回请求轴上值的中位数
Series.min([axis, skipna, level, numeric_only])返回请求轴上值的最小值。
Series.mode([dropna])返回Series中的众数。
Series.nlargest([n, keep])返回值最大的 n 个元素。
Series.nsmallest([n, keep])返回值最小的 n 个元素。
Series.pct_change([periods, fill_method, …])Percentage change between the current and a prior element.
Series.prod([axis, skipna, level, …])返回请求轴上值的乘积。
Series.quantile([q, interpolation])返回指定的分位数。
Series.rank([axis, method, numeric_only, …])Compute numerical data ranks (1 through n) along axis.
Series.sem([axis, skipna, level, ddof, …])Return unbiased standard error of the mean over requested axis.
Series.skew([axis, skipna, level, numeric_only])Return unbiased skew over requested axis.
Series.std([axis, skipna, level, ddof, …])Return sample standard deviation over requested axis.
Series.sum([axis, skipna, level, …])返回请求轴上值的总和。
Series.var([axis, skipna, level, ddof, …])Return unbiased variance over requested axis.
Series.kurtosis([axis, skipna, level, …])Return unbiased kurtosis over requested axis.
Series.unique()返回 Series 中的唯一值。
Series.nunique([dropna])返回 Series 中的唯一值的个数。
Series.is_unique返回Series的元素是否都是唯一值。
Series.is_monotonic返回Series的元素是否单调递增(即升序)。
Series.is_monotonic_increasingis_monotonic的别名。
Series.is_monotonic_decreasing返回Series的元素是否单调递减(即降序)。
Series.value_counts([normalize, sort, …])返回包含唯一值计数的Series。

Reindexing / selection / label manipulation:索引/选择/标签操作

API功能解读
Series.align(other[, join, axis, level, …])Align two objects on their axes with the specified join method.
Series.drop([labels, axis, index, columns, …])根据指定标签移除值。
Series.droplevel(level[, axis])Return Series/DataFrame with requested index / column level(s) removed.
Series.drop_duplicates([keep, inplace])移除Series中的重复值。
Series.duplicated([keep])显示Series中的重复值。
Series.equals(other)测试两个Series是否相等。
Series.first(offset)Select initial periods of time series data based on a date offset.
Series.head([n])返回Series前n行。
Series.idxmax([axis, skipna])返回最大值的行标签。
Series.idxmin([axis, skipna])返回最小值的行标签。
Series.isin(values)Series中的值是否包含在values中。返回值为布尔Series。
Series.last(offset)Select final periods of time series data based on a date offset.
Series.reindex([index])替换Series的行标签,可选择填充逻辑。
Series.reindex_like(other[, method, copy, …])Return an object with matching indices as other object.
Series.rename([index, axis, copy, inplace, …])修改Series的行标签或名称。
Series.rename_axis([mapper, index, columns, …])Set the name of the axis for the index or columns.
Series.reset_index([level, drop, name, inplace])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.take(indices[, axis, is_copy])Return the elements in the given positional indices along an axis.
Series.tail([n])返回Series后n行。
Series.truncate([before, after, axis, copy])Truncate a Series or DataFrame before and after some index value.
Series.where(cond[, other, inplace, axis, …])Replace values where the condition is False.
Series.mask(cond[, other, inplace, axis, …])Replace values where the condition is True.
Series.add_prefix(prefix)Prefix labels with string prefix.
Series.add_suffix(suffix)Suffix labels with string suffix.
Series.filter([items, like, regex, axis])Subset the dataframe rows or columns according to the specified index labels.

Missing data handling:处理缺失值

API功能解读
Series.backfill([axis, inplace, limit, downcast])DataFrame.fillna(method='bfill') 的同义词。
Series.bfill([axis, inplace, limit, downcast])DataFrame.fillna(method='bfill') 的同义词。
Series.ffill([axis, inplace, limit, downcast])DataFrame.fillna(method='ffill') 的同义词。
Series.pad([axis, inplace, limit, downcast])DataFrame.fillna(method='ffill') 的同义词。
Series.dropna([axis, inplace, how])移除Series中的缺失值。
Series.fillna([value, method, axis, …])使用特定方法填充缺失值。
Series.interpolate([method, axis, limit, …])使用插值方法填充缺失值。
Series.isna()检测缺失值。
Series.isnull()检测缺失值。
Series.notna()检测是否存在非缺失值。
Series.notnull()检测是否存在非缺失值。
Series.replace([to_replace, value, inplace, …])Replace values given in to_replace with value.

Reshaping, sorting:重构,排序

API功能解读
Series.argsort([axis, kind, order])返回Series值排序后值的原整数索引。
Series.argmin([axis, skipna])返回Series中值最小的元素的整数索引。
Series.argmax([axis, skipna])返回Series中值最大的元素的整数索引。
Series.reorder_levels(order)Rearrange index levels using input order.
Series.sort_values([axis, ascending, …])根据值对Series排序。
Series.sort_index([axis, level, ascending, …])根据索引标签对Series排序。
Series.swaplevel([i, j, copy])Swap levels i and j in a MultiIndex.
Series.unstack([level, fill_value])Unstack, also known as pivot, Series with MultiIndex to produce DataFrame.
Series.explode([ignore_index])Transform each element of a list-like to a row.
Series.searchsorted(value[, side, sorter])Find indices where elements should be inserted to maintain order.
Series.ravel([order])返回Series基础数据的展平数组
Series.repeat(repeats[, axis])重复Series的元素。
Series.squeeze([axis])将仅有1个元素的Series转换为标量。
Series.view([dtype])创建一个Series的视图。

Combining / comparing / joining / merging:对比,合并,连接

API功能解读
Series.append(to_append[, ignore_index, …])合并两个以上Series。
Series.update(other)按标签对齐将Series对应元素的值修改为other。
Series.compare(other[, align_axis, …])比较另一个Series 并显示两者之间的差别。

Time Series-related

API功能解读
Series.asfreq(freq[, method, how, …])Convert time series to specified frequency.
Series.asof(where[, subset])Return the last row(s) without any NaNs before where.
Series.shift([periods, freq, axis, fill_value])Shift index by desired number of periods with an optional time freq.
Series.first_valid_index()Return index for first non-NA value or None, if no NA value is found.
Series.last_valid_index()Return index for last non-NA value or None, if no NA value is found.
Series.resample(rule[, axis, closed, label, …])Resample time-series data.
Series.tz_convert(tz[, axis, level, copy])Convert tz-aware axis to target time zone.
Series.tz_localize(tz[, axis, level, copy, …])Localize tz-naive index of a Series or DataFrame to target time zone.
Series.at_time(time[, asof, axis])Select values at particular time of day (e.g., 9:30AM).
Series.between_time(start_time, end_time[, …])Select values between particular times of the day (e.g., 9:00-9:30 AM).
Series.tshift([periods, freq, axis])(DEPRECATED) Shift the time index, using the index’s frequency if available.
Series.slice_shift([periods, axis])(DEPRECATED) Equivalent to shift without copying data.

Accessors:存取器

pandas provides dtype-specific methods under various accessors. These are separate namespaces within Series that only apply to specific data types.

Data TypeAccessor
Datetime, Timedelta, Perioddt
Stringstr
Categoricalcat
Sparsesparse

Datetimelike properties:类日期时间属性

Series.dt can be used to access the values of the series as datetimelike and return several properties. These can be accessed like Series.dt.<property>.

Series.dt 可以用于获取类日期时间Series的值,并返回若干属性。 These can be accessed like Series.dt.<property>.

Datetime properties:日期时间属性
API功能解读
Series.dt.date返回datetime.date对象。(不包含时区信息)
Series.dt.time返回datetime.time对象。
Series.dt.timetzReturns numpy array of datetime.time also containing timezone information.
Series.dt.yeardatetime的年份。
Series.dt.monthdatetime的月份。 January=1, December=12。
Series.dt.daydatetime的日期。
Series.dt.hourdatetime的小时。
Series.dt.minutedatetime的分钟。
Series.dt.seconddatetime的秒。
Series.dt.microseconddatetime的毫秒。
Series.dt.nanoseconddatetime的纳秒。
Series.dt.week周数。(已废弃)
Series.dt.weekofyear周数。(已废弃)
Series.dt.dayofweek星期数。Monday=0, Sunday=6.
Series.dt.day_of_week星期数。Monday=0, Sunday=6.
Series.dt.weekday星期数。Monday=0, Sunday=6.
Series.dt.dayofyear天序数。
Series.dt.day_of_year天序数。
Series.dt.quarter季度数。
Series.dt.is_month_start显示日期是否是该月的第一天。
Series.dt.is_month_end显示日期是否是该月的最后一天。
Series.dt.is_quarter_start显示日期是否是该季度的第一天。
Series.dt.is_quarter_end显示日期是否是该季度的最后一天。
Series.dt.is_year_start显示日期是否是该年的第一天。
Series.dt.is_year_end显示日期是否是该年的最后一天。
Series.dt.is_leap_year显示日期所在年份是否是闰年。
Series.dt.daysinmonth显示日期所在月份的总天数。
Series.dt.days_in_month显示日期所在月份的总天数。
Series.dt.tz返回时区信息。
Series.dt.freq返回PeriodArray的频率对象。
Datetime methods:日期时间方法
API功能解读
Series.dt.to_period(*args, **kwargs)Cast to PeriodArray/Index at a particular frequency.
Series.dt.to_pydatetime()以原生Python Datetime对象数组形式返回日期数据。
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)将时间转换为子夜时分。
Series.dt.strftime(*args, **kwargs)使用特定日期格式字符串将日期转换为字符串。
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)根据指定区域设置返回日期的月名称,例如January。
Series.dt.day_name(*args, **kwargs)根据指定区域设置返回日期的星期名称,例如Monday。
Period properties
API功能解读
Series.dt.qyear
Series.dt.start_time
Series.dt.end_time
Timedelta properties
API功能解读
Series.dt.daysNumber of days for each element.
Series.dt.secondsNumber of seconds (>= 0 and less than 1 day) for each element.
Series.dt.microsecondsNumber of microseconds (>= 0 and less than 1 second) for each element.
Series.dt.nanosecondsNumber of nanoseconds (>= 0 and less than 1 microsecond) for each element.
Series.dt.componentsReturn a Dataframe of the components of the Timedeltas.
Timedelta methods
API功能解读
Series.dt.to_pytimedelta()Return an array of native datetime.timedelta objects.
Series.dt.total_seconds(*args, **kwargs)Return total duration of each element expressed in seconds.

String handling:字符串处理

Series.str can be used to access the values of the series as strings and apply several methods to it. These can be accessed like Series.str.<function/property>.

API功能解读
大小写转换
Series.str.capitalize()将Series/Index中的字符串首字母转换为大写。
Series.str.title()将Series/Index中的字符串各单词的首字母转换为大写。
Series.str.casefold()将Series/Index中的字符串转换为小写。(支持所有语言)
Series.str.lower()将Series/Index中的字符串转换为小写。(仅支持A-Z)
Series.str.upper()将Series/Index中的字符串转换为大写。
Series.str.swapcase()互换Series/Index中的字符串大小写。
字符串修整、替换
Series.str.strip([to_strip])移除Series/Index中的字符串左右两侧的字符(默认为空格)
Series.str.lstrip([to_strip])移除Series/Index中的字符串左侧的字符。
Series.str.rstrip([to_strip])移除Series/Index中的字符串右侧的字符。
Series.str.replace(pat, repl[, n, case, …])Replace each occurrence of pattern/regex in the Series/Index.
Series.str.translate(table)根据指定映射表转换Series/Index中的字符串中的字符。
字符串拼接
Series.str.cat([others, sep, na_rep, join])Concatenate strings in the Series/Index with given separator.
Series.str.join(sep)Join lists contained as elements in the Series/Index with passed delimiter.
字符串查找
Series.str.contains(pat[, case, flags, na, …])
Series.str.find(sub[, start, end])Return lowest indexes in each strings in the Series/Index.
Series.str.rfind(sub[, start, end])Return highest 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.
Series.str.match(pat[, case, flags, na])Determine if each string starts with a match of a regular expression.
Series.str.fullmatch(pat[, case, flags, na])Determine if each string entirely matches a regular expression.
Series.str.index(sub[, start, end])Return lowest indexes in each string in Series/Index.
Series.str.rindex(sub[, start, end])Return highest indexes in each string in Series/Index.
Series.str.startswith(pat[, na])Test if the start of each string element matches a pattern.
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.get(i)Extract element from each component at specified position.
字符串计数
Series.str.len()返回Series/Index中的每个元素的长度。
Series.str.count(pat[, flags])检测Series/Index中各字符串中模式或正则表达式出现的次数。
字符串分割
Series.str.partition([sep, expand])Split the string at the first occurrence of sep.
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.rpartition([sep, expand])Split the string at the last occurrence of sep.
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.center(width[, fillchar])在Series/Index中的字符串左右两侧填充字符串。
Series.str.pad(width[, side, fillchar])在Series/Index中的字符串左右两侧填充字符串达到指定宽度。
Series.str.ljust(width[, fillchar])在Series/Index中的字符串左侧填充字符串达到指定宽度。
Series.str.rjust(width[, fillchar])在Series/Index中的字符串右侧填充字符串达到指定宽度。
Series.str.repeat(repeats)根据指定次数复制Series/Index中的字符串。
Series.str.wrap(width, **kwargs)根据指定宽度对Series/Index中各字符串强制换行。
Series.str.zfill(width)在Series/Index中的字符串开头填充指定数量的0。
字符检测
Series.str.isalnum()检测Series/Index中的字符串的所有字符是否均为数字或字母。
Series.str.isalpha()检测Series/Index中的字符串的所有字符是否均为字母。
Series.str.isdecimal()检测Series/Index中的字符串的是否为十进制数。(上下标不识别为数字)
Series.str.isdigit()检测Series/Index中的字符串的所有字符是否均为数字。(上下标识别为数字)
Series.str.isnumeric()检测Series/Index中的字符串的是否为数字。(上下标、分数、百分数均识别为数字)
Series.str.isspace()检测Series/Index中的字符串的所有字符是否均为空白。
Series.str.islower()检测Series/Index中的字符串的所有字符是否均为小写。
Series.str.isupper()检测Series/Index中的字符串的所有字符是否均为大写。
Series.str.istitle()检测Series/Index中的字符串的所有单词首字母是否均为大写。
杂项
Series.str.decode(encoding[, errors])按指定编码对Series/Index中的字符串进行解码。
Series.str.encode(encoding[, errors])按指定编码对Series/Index中的字符串进行编码。
Series.str.normalize(form)返回Series/Index中的每个字符串的Unicode范式。
Series.str.get_dummies([sep])Return DataFrame of dummy/indicator variables for Series.

Categorical accessor

Categorical-dtype specific methods and attributes are available under the Series.cat accessor.

API功能解读
Series.cat.categoriesThe categories of this categorical.
Series.cat.orderedWhether the categories have an ordered relationship.
Series.cat.codesReturn Series of codes as well as the index.
Series.cat.rename_categories(*args, **kwargs)Rename categories.
Series.cat.reorder_categories(*args, **kwargs)Reorder categories as specified in new_categories.
Series.cat.add_categories(*args, **kwargs)Add new categories.
Series.cat.remove_categories(*args, **kwargs)Remove the specified categories.
Series.cat.remove_unused_categories(*args, …)Remove categories which are not used.
Series.cat.set_categories(*args, **kwargs)Set the categories to the specified new_categories.
Series.cat.as_ordered(*args, **kwargs)Set the Categorical to be ordered.
Series.cat.as_unordered(*args, **kwargs)Set the Categorical to be unordered.

Sparse accessor

Sparse-dtype specific methods and attributes are provided under the Series.sparse accessor.

API功能解读
Series.sparse.npointsThe number of non- fill_value points.
Series.sparse.densityThe percent of non- fill_value points, as decimal.
Series.sparse.fill_valueElements in data that are fill_value are not stored.
Series.sparse.sp_valuesAn ndarray containing the non- fill_value values.
Series.sparse.from_coo(A[, dense_index])Create a Series with sparse values from a scipy.sparse.coo_matrix.
Series.sparse.to_coo([row_levels, …])Create a scipy.sparse.coo_matrix from a Series with MultiIndex.

Flags

Flags refer to attributes of the pandas object. Properties of the dataset (like the date is was recorded, the URL it was accessed from, etc.) should be stored in Series.attrs.

API功能解读
Flags(obj, *, allows_duplicate_labels)Flags that apply to pandas objects.

Metadata:元数据

Series.attrs is a dictionary for storing global metadata for this Series.

Warning

Series.attrs is considered experimental and may change without warning.

API功能解读
Series.attrsDictionary of global attributes of this dataset.

Plotting:绘图

Series.plot is both a callable method and a namespace attribute for specific plotting methods of the form Series.plot.<kind>.

API功能解读
Series.plot([kind, ax, figsize, …])Series plotting accessor and method
Series.plot.area([x, y])Draw a stacked area plot.
Series.plot.bar([x, y])Vertical bar plot.
Series.plot.barh([x, y])Make a horizontal bar plot.
Series.plot.box([by])Make a box plot of the DataFrame columns.
Series.plot.density([bw_method, ind])Generate Kernel Density Estimate plot using Gaussian kernels.
Series.plot.hist([by, bins])Draw one histogram of the DataFrame’s columns.
Series.plot.kde([bw_method, ind])Generate Kernel Density Estimate plot using Gaussian kernels.
Series.plot.line([x, y])Plot Series or DataFrame as lines.
Series.plot.pie(**kwargs)Generate a pie plot.
Series.hist([by, ax, grid, xlabelsize, …])Draw histogram of the input series using matplotlib.

Serialization / IO / conversion:序列化/IO/转换

API功能解读
Series.to_pickle(path[, compression, …])Pickle (serialize) object to file.
Series.to_csv([path_or_buf, sep, na_rep, …])Write object to a comma-separated values (csv) file.
Series.to_dict([into])Convert Series to {label -> value} dict or dict-like object.
Series.to_excel(excel_writer[, sheet_name, …])Write object to an Excel sheet.
Series.to_frame([name])Convert Series to DataFrame.
Series.to_xarray()Return an xarray object from the pandas object.
Series.to_hdf(path_or_buf, key[, mode, …])Write the contained data to an HDF5 file using HDFStore.
Series.to_sql(name, con[, schema, …])Write records stored in a DataFrame to a SQL database.
Series.to_json([path_or_buf, orient, …])Convert the object to a JSON string.
Series.to_string([buf, na_rep, …])Render a string representation of the Series.
Series.to_clipboard([excel, sep])Copy object to the system clipboard.
Series.to_latex([buf, columns, col_space, …])Render object to a LaTeX tabular, longtable, or nested table/tabular.
Series.to_markdown([buf, mode, index, …])Print Series in Markdown-friendly format.
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值