Series¶
构造函数¶
|
属性¶
坐标轴
The index (axis labels) of the Series. |
Return the dtype object of the underlying data. |
|
Return the transpose, which is by definition self. |
|
Return an int representing the number of axes / array dimensions. |
|
|
Return the memory usage of the Series. |
转换¶
|
Cast a pandas object to a specified dtype |
|
Make a copy of this object's indices and data. |
|
Convert Series to DataFrame. |
|
索引和迭代¶
Access a single value for a row/column label pair. |
|
|
Lazily iterate over (index, value) tuples. |
|
Lazily iterate over (index, value) tuples. |
|
Replace values where the condition is True. |
|
Replace values where the condition is False. |
二元运算函数¶
|
Return Addition of series and other, element-wise (binary operator add). |
|
Return Subtraction of series and other, element-wise (binary operator subtract). |
|
Return Multiplication of series and other, element-wise (binary operator mul). |
|
Return Floating division of series and other, element-wise (binary operator truediv). |
|
Return Floating division of series and other, element-wise (binary operator truediv). |
|
Return Integer division of series and other, element-wise (binary operator floordiv). |
|
Return Modulo of series and other, element-wise (binary operator mod). |
|
Return Exponential power of series and other, element-wise (binary operator pow). |
|
Return Addition of series and other, element-wise (binary operator radd). |
|
Return Subtraction of series and other, element-wise (binary operator rsubtract). |
|
Return Multiplication of series and other, element-wise (binary operator rmul). |
|
Return Floating division of series and other, element-wise (binary operator rtruediv). |
|
Return Floating division of series and other, element-wise (binary operator rtruediv). |
|
Return Integer division of series and other, element-wise (binary operator rfloordiv). |
|
Return Modulo of series and other, element-wise (binary operator rmod). |
|
Return Exponential power of series and other, element-wise (binary operator rpow). |
|
Return Less than of series and other, element-wise (binary operator lt). |
|
Return Greater than of series and other, element-wise (binary operator gt). |
|
Return Less than or equal to of series and other, element-wise (binary operator le). |
|
Return Greater than or equal to of series and other, element-wise (binary operator ge). |
|
Return Not equal to of series and other, element-wise (binary operator ne). |
|
Return Equal to of series and other, element-wise (binary operator eq). |
|
Compute the dot product between the Series and the columns of other. |
应用函数、分组和窗口¶
|
Invoke function on values of Series. |
|
|
|
|
|
Call |
|
Map values of Series according to input correspondence. |
|
|
|
Provide rolling window calculations. |
|
Provide expanding transformations. |
|
Provide exponential weighted functions. |
计算和描述统计¶
|
|
|
|
|
Compute the lag-N autocorrelation. |
|
Return boolean Series equivalent to left <= series <= right. |
|
Compute correlation with other Series, excluding missing values. |
|
|
|
|
|
|
|
|
|
|
|
|
Return boolean scalar if values in the object are monotonic_increasing. |
|
Return boolean scalar if values in the object are monotonic_decreasing. |
|
Return boolean scalar if values in the object are monotonic_increasing. |
|
|
|
|
|
|
|
|
|
|
Return the median of the values over the requested axis. |
|
|
|
Percentage change between the current and a prior element. |
|
|
|
|
|
Return value at the given quantile. |
|
Round each value in a Series to the given number of decimals. |
|
|
|
|
|
|
|
|
|
|
|
Return number of unique elements in the object. |
|
Return a Series containing counts of unique values. |
重设索引、选择和标签操作¶
|
Prefix labels with string prefix. |
|
Return Series with specified index labels removed. |
|
Return Series with duplicate values removed. |
|
Indicate duplicate Series values. |
|
Return the first n rows. |
|
Whether elements in Series are contained in values. |
|
Conform Series/DataFrame to new index with optional filling logic. |
|
Return an object with matching indices as other object. |
|
Alter Series index labels or name. |
|
Set the name of the axis for the index or columns. |
|
Generate a new DataFrame or Series with the index reset. |
|
Return a random sample of items from an axis of object. |
|
Assign desired index to given axis. |
|
Return the last n rows. |
缺失值处理¶
Detect missing values. |
|
Detect existing (non-missing) values. |
|
|
Return a new Series with missing values removed. |
|
Fill NA/NaN values using the specified method. |
形状变换和排序¶
|
Transform each element of a list-like to a row. |
|
Sort by the values. |
|
Sort object by labels (along an axis). |
数据合并¶
|
类型访问器¶
Pandas 提供了针对不同数据类型的访问器。下面列出了 Series
下只针对特定类型的独立名称空间。
数据类型 |
访问器 |
---|---|
日期时间、时间差和时间段 |
|
字符串 |
日期时间类属性¶
Series.dt
可被用于访问日期时间类型的 Series,返回若干个属性值。这些属性值可通过 Series.dt.<property>
来调用。
日期时间属性¶
Returns numpy array of python datetime.date objects (namely, the date part of Timestamps without timezone information). |
|
Returns numpy array of datetime.time. |
|
Returns numpy array of datetime.time also containing timezone information. |
|
The year of the datetime. |
|
The month as January=1, December=12. |
|
The day of the datetime. |
|
The hours of the datetime. |
|
The minutes of the datetime. |
|
The seconds of the datetime. |
|
The microseconds of the datetime. |
|
The nanoseconds of the datetime. |
|
The week ordinal of the year. |
|
The week ordinal of the year. |
|
The day of the week with Monday=0, Sunday=6. |
|
The day of the week with Monday=0, Sunday=6. |
|
The ordinal day of the year. |
|
The quarter of the date. |
|
Indicates whether the date is the first day of the month. |
|
Indicates whether the date is the last day of the month. |
|
Indicator for whether the date is the first day of a quarter. |
|
Indicator for whether the date is the last day of a quarter. |
|
Indicate whether the date is the first day of a year. |
|
Indicate whether the date is the last day of the year. |
|
Boolean indicator if the date belongs to a leap year. |
|
The number of days in the month. |
|
The number of days in the month. |
|
Return timezone, if any. |
|
日期时间方法¶
|
Cast to PeriodArray/Index at a particular frequency. |
Return the data as an array of native Python datetime objects. |
|
|
Localize tz-naive Datetime Array/Index to tz-aware Datetime Array/Index. |
|
Convert tz-aware Datetime Array/Index from one time zone to another. |
|
Convert times to midnight. |
|
Convert to Index using specified date_format. |
|
Perform round operation on the data to the specified freq. |
|
Perform floor operation on the data to the specified freq. |
|
Perform ceil operation on the data to the specified freq. |
|
Return the month names of the DateTimeIndex with specified locale. |
|
Return the day names of the DateTimeIndex with specified locale. |
时间段属性¶
时间差属性¶
Number of days for each element. |
|
Number of seconds (>= 0 and less than 1 day) for each element. |
|
Number of microseconds (>= 0 and less than 1 second) for each element. |
|
Number of nanoseconds (>= 0 and less than 1 microsecond) for each element. |
|
Return a Dataframe of the components of the Timedeltas. |
时间差方法¶
Return an array of native datetime.timedelta objects. |
|
|
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. |
|
|
Concatenate strings in the Series/Index with given separator. |
|
Pad left and right side of strings in the Series/Index. |
|
Test if pattern or regex is contained within a string of a Series or Index. |
|
Count occurrences of pattern in each string of the Series/Index. |
|
Decode character string in the Series/Index using indicated encoding. |
|
Encode character string in the Series/Index using indicated encoding. |
|
Test if the end of each string element matches a pattern. |
|
Extract capture groups in the regex pat as columns in a DataFrame. |
|
Extract capture groups in the regex pat as columns in DataFrame. |
|
Return lowest indexes in each strings in the Series/Index. |
|
Find all occurrences of pattern or regular expression in the Series/Index. |
Extract element from each component at specified position. |
|
|
Return lowest indexes in each string in Series/Index. |
|
Join lists contained as elements in the Series/Index with passed delimiter. |
Compute the length of each element in the Series/Index. |
|
|
Pad right side of strings in the Series/Index. |
Convert strings in the Series/Index to lowercase. |
|
|
Remove leading characters. |
|
Determine if each string starts with a match of a regular expression. |
|
Return the Unicode normal form for the strings in the Series/Index. |
|
Pad strings in the Series/Index up to width. |
|
Split the string at the first occurrence of sep. |
|
Duplicate each string in the Series or Index. |
|
Replace each occurrence of pattern/regex in the Series/Index. |
|
Return highest indexes in each strings in the Series/Index. |
|
Return highest indexes in each string in Series/Index. |
|
Pad left side of strings in the Series/Index. |
|
Split the string at the last occurrence of sep. |
|
Remove trailing characters. |
|
Slice substrings from each element in the Series or Index. |
|
Replace a positional slice of a string with another value. |
|
Split strings around given separator/delimiter. |
|
Split strings around given separator/delimiter. |
|
Test if the start of each string element matches a pattern. |
|
Remove leading and trailing characters. |
Convert strings in the Series/Index to be swapcased. |
|
Convert strings in the Series/Index to titlecase. |
|
|
Map all characters in the string through the given mapping table. |
Convert strings in the Series/Index to uppercase. |
|
|
Wrap strings in Series/Index at specified line 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 whitespace. |
|
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>
提供特定画图方法的属性。
alias of |
|
Draw a stacked area plot. |
|
Vertical bar plot. |
|
Make a horizontal bar plot. |
|
Make a box plot of the DataFrame columns. |
|
Generate Kernel Density Estimate plot using Gaussian kernels. |
|
Draw one histogram of the DataFrame's columns. |
|
Generate Kernel Density Estimate plot using Gaussian kernels. |
|
Plot Series or DataFrame as lines. |
|
Generate a pie plot. |
序列化、IO 和转换¶
|
Write object to a comma-separated values (csv) file. |
|
Write records stored in a DataFrame to a SQL database. |
Misc¶
|
Apply function to each chunk. |