Series#

建構函式#

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

一維 ndarray,帶有軸標籤(包括時間序列)。

屬性#

Series.index

Series 的索引(軸標籤)。

Series.array

此 Series 或 Index 所依據資料的 ExtensionArray。

Series.values

根據 dtype,將 Series 傳回為 ndarray 或類似 ndarray 的資料。

Series.dtype

傳回基礎資料的 dtype 物件。

Series.shape

傳回基礎資料形狀的 tuple。

Series.nbytes

傳回基礎資料的位元組數。

Series.ndim

基礎資料的維度數,定義為 1。

Series.size

傳回基礎資料中的元素數。

Series.T

傳回轉置,定義為 self。

Series.memory_usage([index, deep])

傳回 Series 的記憶體使用量。

Series.hasnans

如果有任何 NaNs,傳回 True。

Series.empty

指標表示 Series/DataFrame 是否為空。

Series.dtypes

傳回基礎資料的 dtype 物件。

Series.name

傳回 Series 的名稱。

Series.flags

取得與此 pandas 物件相關的屬性。

Series.set_flags(*[, copy, ...])

傳回一個具有更新旗標的新物件。

轉換#

Series.astype(dtype[, copy, errors])

將 pandas 物件轉換為指定的資料類型 dtype

Series.convert_dtypes([infer_objects, ...])

使用支援 pd.NA 的資料類型,將欄位轉換為最佳可能的資料類型。

Series.infer_objects([copy])

嘗試為物件欄位推斷更好的資料類型。

Series.copy([deep])

複製此物件的索引和資料。

Series.bool()

(已棄用)傳回單一元素 Series 或 DataFrame 的布林值。

Series.to_numpy([dtype, copy, na_value])

一個 NumPy ndarray,表示此 Series 或 Index 中的值。

Series.to_period([freq, copy])

將 Series 從 DatetimeIndex 轉換為 PeriodIndex。

Series.to_timestamp([freq, how, copy])

轉換為 Timestamp 的 DatetimeIndex,在區間的開頭

Series.to_list()

傳回值清單。

Series.__array__([dtype])

傳回值作為 NumPy 陣列。

索引、反覆運算#

Series.get(key[, default])

取得物件中給定金鑰的項目(例如:DataFrame 欄位)。

Series.at

存取列/欄位標籤配對的單一值。

Series.iat

依整數位置存取列/欄位配對的單一值。

Series.loc

依標籤或布林陣列存取一組列和欄位。

Series.iloc

(已停用)純粹基於整數位置的索引,依位置選取。

Series.__iter__()

傳回值的反覆運算器。

Series.items()

以惰性方式反覆運算 (index, value) tuple。

Series.keys()

傳回索引的別名。

Series.pop(item)

傳回項目並從 series 中刪除。

Series.item()

傳回基礎資料的第一個元素,作為 Python 標量。

Series.xs(key[, axis, level, drop_level])

從 Series/DataFrame 傳回橫切面。

有關 .at.iat.loc.iloc 的詳細資訊,請參閱 索引文件

二元運算子函數#

Series.add(other[, level, fill_value, axis])

傳回 series 和 other 的加法,逐元素(二元運算子 add)。

Series.sub(other[, level, fill_value, axis])

傳回 series 和 other 的減法,逐元素(二元運算子 sub)。

Series.mul(other[, level, fill_value, axis])

傳回 series 和 other 的乘法,逐元素(二元運算子 mul)。

Series.div(other[, level, fill_value, axis])

傳回 series 和 other 的浮點除法,逐元素(二元運算子 truediv)。

Series.truediv(other[, level, fill_value, axis])

傳回 series 和 other 的浮點除法,逐元素(二元運算子 truediv)。

Series.floordiv(other[, level, fill_value, axis])

傳回序列與其他元素的整數除法(二元運算子 floordiv)。

Series.mod(other[, level, fill_value, axis])

傳回序列與其他元素的模數(二元運算子 mod)。

Series.pow(other[, level, fill_value, axis])

傳回序列與其他元素的指數運算(二元運算子 pow)。

Series.radd(other[, level, fill_value, axis])

傳回序列與其他元素的加法(二元運算子 radd)。

Series.rsub(other[, level, fill_value, axis])

傳回序列與其他元素的減法(二元運算子 rsub)。

Series.rmul(other[, level, fill_value, axis])

傳回序列與其他元素的乘法(二元運算子 rmul)。

Series.rdiv(other[, level, fill_value, axis])

傳回序列和其它項目的浮點除法,逐元素(二元運算子 rtruediv)。

Series.rtruediv(other[, level, fill_value, axis])

傳回序列和其它項目的浮點除法,逐元素(二元運算子 rtruediv)。

Series.rfloordiv(other[, level, fill_value, ...])

傳回序列和其它項目的整數除法,逐元素(二元運算子 rfloordiv)。

Series.rmod(other[, level, fill_value, axis])

傳回序列和其它項目的模數,逐元素(二元運算子 rmod)。

Series.rpow(other[, level, fill_value, axis])

傳回序列和其它項目的指數冪,逐元素(二元運算子 rpow)。

Series.combine(other, func[, fill_value])

根據 func 將序列與序列或純量結合。

Series.combine_first(other)

使用「其它」中相同位置的值更新空值元素。

Series.round([decimals])

將序列中的每個值四捨五入到給定的位數。

Series.lt(other[, level, fill_value, axis])

傳回序列和 other 的小於,逐元素(二元運算子 lt)。

Series.gt(other[, level, fill_value, axis])

傳回序列和 other 的大於,逐元素(二元運算子 gt)。

Series.le(other[, level, fill_value, axis])

傳回序列和小於或等於,逐元素(二元運算子 le)。

Series.ge(other[, level, fill_value, axis])

傳回序列和大於或等於,逐元素(二元運算子 ge)。

Series.ne(other[, level, fill_value, axis])

傳回序列和不等於,逐元素(二元運算子 ne)。

Series.eq(other[, level, fill_value, axis])

傳回序列和等於,逐元素(二元運算子 eq)。

Series.product([axis, skipna, numeric_only, ...])

傳回請求軸上值的乘積。

Series.dot(other)

計算 Series 和 other 欄位的點乘積。

函數應用、GroupBy 和視窗#

Series.apply(func[, convert_dtype, args, by_row])

在 Series 的值上呼叫函數。

Series.agg([func, axis])

使用一個或多個作業在指定的軸上進行彙總。

Series.aggregate([func, axis])

使用一個或多個作業在指定的軸上進行彙總。

Series.transform(func[, axis])

在 self 上呼叫 func,產生與 self 具有相同軸狀的 Series。

Series.map(arg[, na_action])

根據輸入對應或函數對 Series 的值進行對應。

Series.groupby([by, axis, level, as_index, ...])

使用對應器或欄位 Series 對 Series 進行分組。

Series.rolling(window[, min_periods, ...])

提供滾動視窗計算。

Series.expanding([min_periods, axis, method])

提供擴展視窗計算。

Series.ewm([com, span, halflife, alpha, ...])

提供指數加權 (EW) 計算。

Series.pipe(func, *args, **kwargs)

套用可鏈結且預期為 Series 或 DataFrames 的函式。

計算 / 描述性統計#

Series.abs()

傳回一個 Series/DataFrame,其中包含每個元素的絕對數字值。

Series.all([axis, bool_only, skipna])

傳回是否所有元素都為 True,可能會透過軸向進行。

Series.any([, axis, bool_only, skipna])

傳回是否有任何元素為 True,可能會透過軸向進行。

Series.autocorr([lag])

計算延遲 N 的自相關。

Series.between(left, right[, inclusive])

傳回布林 Series,等於 left <= series <= right。

Series.clip([lower, upper, axis, inplace])

在輸入閾值處修剪值。

Series.corr(other[, method, min_periods])

計算與 other Series 的相關性,不包括遺失值。

Series.count()

傳回 Series 中非 NA/null 觀測值的數量。

Series.cov(other[, min_periods, ddof])

計算與 Series 的共變異數,不包括遺失值。

Series.cummax([axis, skipna])

傳回 DataFrame 或 Series 軸上的累計最大值。

Series.cummin([axis, skipna])

傳回 DataFrame 或 Series 軸上的累計最小值。

Series.cumprod([axis, skipna])

傳回 DataFrame 或 Series 軸上的累計乘積。

Series.cumsum([axis, skipna])

傳回資料框或序列軸上的累計總和。

Series.describe([百分位數, 包含, 排除])

產生描述性統計資料。

Series.diff([週期])

元素的第一個離散差。

Series.factorize([排序, 使用_na_哨兵])

將物件編碼為列舉類型或分類變數。

Series.kurt([軸, 略過_na, 僅數值])

傳回請求軸上的無偏峰度。

Series.max([軸, 略過_na, 僅數值])

傳回請求軸上數值的最大值。

Series.mean([軸, 略過_na, 僅數值])

傳回請求軸上數值的平均值。

Series.median([軸, 略過_na, 僅數值])

傳回請求軸上數值的中位數。

Series.min([軸, 略過_na, 僅數值])

傳回請求軸上數值的最小值。

Series.mode([dropna])

傳回 Series 的眾數。

Series.nlargest([n, keep])

傳回最大的 n 個元素。

Series.nsmallest([n, keep])

傳回最小的 n 個元素。

Series.pct_change([periods, fill_method, ...])

當前元素與前一個元素之間的分數變化。

Series.prod([axis, skipna, numeric_only, ...])

傳回請求軸上值的乘積。

Series.quantile([q, interpolation])

傳回給定分位數的值。

Series.rank([axis, method, numeric_only, ...])

沿著軸線計算數值資料的排名 (1 到 n)。

Series.sem([axis, skipna, ddof, numeric_only])

傳回請求軸線上平均數的無偏標準誤差。

Series.skew([axis, skipna, numeric_only])

傳回請求軸線上的無偏歪度。

Series.std([axis, skipna, ddof, numeric_only])

傳回請求軸上的樣本標準差。

Series.sum([axis, skipna, numeric_only, ...])

傳回請求軸上數值的總和。

Series.var([axis, skipna, ddof, numeric_only])

傳回請求軸上的無偏方差。

Series.kurtosis([axis, skipna, numeric_only])

傳回請求軸上的無偏峰度。

Series.unique()

傳回 Series 物件的唯一值。

Series.nunique([dropna])

傳回物件中唯一元素的數量。

Series.is_unique

如果物件中的值是唯一的,傳回布林值。

Series.is_monotonic_increasing

如果物件中的值是單調遞增的,傳回布林值。

Series.is_monotonic_decreasing

如果物件中的值是單調遞減的,傳回布林值。

Series.value_counts([normalize, sort, ...])

傳回包含唯一值計數的 Series。

重新索引 / 選取 / 標籤操作#

Series.align(other[, join, axis, level, ...])

使用指定的連接方法在軸線上對齊兩個物件。

Series.case_when(caselist)

替換條件為 True 的值。

Series.drop([labels, axis, index, columns, ...])

傳回已移除指定索引標籤的 Series。

Series.droplevel(level[, axis])

傳回已移除要求的索引 / 欄位層級的 Series/DataFrame。

Series.drop_duplicates(*[, keep, inplace, ...])

傳回已移除重複值的 Series。

Series.duplicated([keep])

指出重複的 Series 值。

Series.equals(other)

測試兩個物件是否包含相同的元素。

Series.first(offset)

(已棄用)根據日期偏移量選擇時間序列資料的初始期間。

Series.head([n])

傳回前 n 列。

Series.idxmax([axis, skipna])

傳回最大值的列標籤。

Series.idxmin([axis, skipna])

傳回最小值的列標籤。

Series.isin(values)

Series 中的元素是否包含在 values 中。

Series.last(offset)

(已棄用)根據日期偏移量選擇時間序列資料的最後期間。

Series.reindex([index, axis, method, copy, ...])

將 Series 調整為新的索引,並使用選填的填補邏輯。

Series.reindex_like(other[, method, copy, ...])

傳回與其他物件索引相符的物件。

Series.rename([index, axis, copy, inplace, ...])

變更 Series 索引標籤或名稱。

Series.rename_axis([mapper, index, axis, ...])

設定索引或欄位軸的名稱。

Series.reset_index([level, drop, name, ...])

產生一個新的 DataFrame 或 Series,並重設索引。

Series.sample([n, frac, replace, weights, ...])

從物件的軸傳回一個隨機項目樣本。

Series.set_axis(labels, *[, axis, copy])

將指定的索引指定給指定的軸。

Series.take(indices[, axis])

傳回沿著軸的指定位置索引中的元素。

Series.tail([n])

傳回最後 n 列。

Series.truncate([before, after, axis, copy])

在某個索引值之前和之後截斷 Series 或 DataFrame。

Series.where(cond[, other, inplace, axis, level])

在條件為 False 的地方替換值。

Series.mask(cond[, other, inplace, axis, level])

在條件為 True 的地方替換值。

Series.add_prefix(prefix[, axis])

使用字串 prefix 作為標籤的前綴。

Series.add_suffix(suffix[, axis])

使用字串 suffix 作為標籤的後綴。

Series.filter([items, like, regex, axis])

根據指定的索引標籤,對資料框列或欄進行子集處理。

遺失資料處理#

Series.backfill(*[, axis, inplace, limit, ...])

(已棄用) 使用下一個有效觀測值填補 NA/NaN 值以填補間隙。

Series.bfill(*[, axis, inplace, limit, ...])

使用下一個有效觀測值填補 NA/NaN 值以填補間隙。

Series.dropna(*[, axis, inplace, how, ...])

傳回一個移除遺失值的新 Series。

Series.ffill(*[, axis, inplace, limit, ...])

透過將最後一個有效觀測值傳播到下一個有效值,填補 NA/NaN 值。

Series.fillna([value, method, axis, ...])

使用指定的 method 填補 NA/NaN 值。

Series.interpolate([method, axis, limit, ...])

使用內插法填補 NaN 值。

Series.isna()

偵測遺失值。

Series.isnull()

Series.isnull 是 Series.isna 的別名。

Series.notna()

偵測現有(非遺失)值。

Series.notnull()

Series.notnull 是 Series.notna 的別名。

Series.pad([*, axis, inplace, limit, downcast])

(已棄用)透過將最後一個有效觀察值傳播到下一個有效值來填入 NA/NaN 值。

Series.replace([to_replace, value, inplace, ...])

to_replace 中給定的值替換為 value

變形、排序#

Series.argsort([axis, kind, order, stable])

傳回會對 Series 值進行排序的整數索引。

Series.argmin([axis, skipna])

傳回 Series 中最小值的整數位置。

Series.argmax([axis, skipna])

傳回 Series 中最大值的整數位置。

Series.reorder_levels(order)

使用輸入順序重新排列索引層級。

Series.sort_values([*, axis, ascending, ...])

依據值進行排序。

Series.sort_index(*[, axis, level, ...])

依索引標籤對 Series 進行排序。

Series.swaplevel([i, j, copy])

MultiIndex 中交換層級 i 和 j。

Series.unstack([level, fill_value, sort])

將具有 MultiIndex 的 Series 進行取消堆疊(也稱為樞紐),以產生 DataFrame。

Series.explode([ignore_index])

將類似清單的每個元素轉換成一行。

Series.searchsorted(value[, side, sorter])

找出應插入元素以維持順序的索引。

Series.ravel([order])

(已棄用)將扁平化的基礎資料傳回為 ndarray 或 ExtensionArray。

Series.repeat(repeats[, axis])

重複 Series 的元素。

Series.squeeze([軸])

將 1 維軸物件壓縮為純量。

Series.view([資料型態])

(已棄用) 建立 Series 的新檢視。

合併/比較/連接/合併#

Series.compare(其他[, 對齊軸, ...])

與另一個 Series 比較並顯示差異。

Series.update(其他)

使用傳遞 Series 的值,就地修改 Series。

存取器#

pandas 在各種存取器中提供特定於資料類型的函式。這些是 Series 內部獨立的命名空間,只適用於特定的資料類型。

Series.str

StringMethods 的別名

Series.cat

別名為 CategoricalAccessor

Series.dt

別名為 CombinedDatetimelikeProperties

Series.sparse

別名為 SparseAccessor

DataFrame.sparse

別名為 SparseFrameAccessor

Index.str

StringMethods 的別名

資料類型

存取器

日期時間、時間增量、週期

dt

字串

str

分類

cat

稀疏

sparse

日期時間屬性#

Series.dt 可用於存取系列的日期時間值並傳回多個屬性。這些屬性可透過 Series.dt.<property> 存取。

日期時間屬性#

Series.dt.date

傳回 Python datetime.date 物件的 NumPy 陣列。

Series.dt.time

傳回 datetime.time 物件的 NumPy 陣列。

Series.dt.timetz

傳回具有時區的 datetime.time 物件的 NumPy 陣列。

Series.dt.year

日期時間的年分。

Series.dt.month

月份,1 月為 1,12 月為 12。

Series.dt.day

日期中的天數。

Series.dt.hour

日期中的小時。

Series.dt.minute

日期中的分鐘。

Series.dt.second

日期中的秒數。

Series.dt.microsecond

日期中的微秒。

Series.dt.nanosecond

日期中的奈秒。

Series.dt.dayofweek

星期中的天數,星期一為 0,星期日為 6。

Series.dt.day_of_week

星期中的天數,星期一為 0,星期日為 6。

Series.dt.weekday

星期中的天數,星期一為 0,星期日為 6。

Series.dt.dayofyear

一年中的第幾天。

Series.dt.day_of_year

一年中的第幾天。

Series.dt.days_in_month

月份中的天數。

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 的頻率物件。

Series.dt.unit

Series.dt.normalize(*args, **kwargs)

將時間轉換為午夜。

日期時間方法#

Series.dt.isocalendar()

根據 ISO 8601 標準計算年、週和日。

Series.dt.to_period(*args, **kwargs)

轉換為特定頻率的 PeriodArray/PeriodIndex。

Series.dt.to_pydatetime()

(已棄用)將資料傳回為 datetime.datetime 物件的陣列。

Series.dt.tz_localize(*args, **kwargs)

將時區無感知的 Datetime Array/Index 本地化為時區感知的 Datetime Array/Index。

Series.dt.tz_convert(*args, **kwargs)

將時區感知的 Datetime Array/Index 從一個時區轉換為另一個時區。

Series.dt.normalize(*args, **kwargs)

將時間轉換為午夜。

Series.dt.strftime(*args, **kwargs)

使用指定的 date_format 轉換為 Index。

Series.dt.round(*args, **kwargs)

對資料執行 round 運算,至指定的 freq

Series.dt.floor(*args, **kwargs)

對資料執行 floor 運算,至指定的 freq

Series.dt.ceil(*args, **kwargs)

對資料執行 ceil 運算,並指定 freq

Series.dt.month_name(*args, **kwargs)

傳回指定地區的月份名稱。

Series.dt.day_name(*args, **kwargs)

傳回指定地區的星期名稱。

Series.dt.as_unit(*args, **kwargs)

週期屬性#

Series.dt.qyear

Series.dt.start_time

取得此週期的開始時間戳記。

Series.dt.end_time

取得此週期的結束時間戳記。

時間差屬性#

Series.dt.days

每個元素的天數。

Series.dt.seconds

每個元素的秒數(>= 0 且小於 1 天)。

Series.dt.microseconds

每個元素的微秒數(>= 0 且小於 1 秒)。

Series.dt.nanoseconds

每個元素的奈秒數(>= 0 且小於 1 微秒)。

Series.dt.components

傳回時間差組成的資料框。

Series.dt.unit

時間差方法#

Series.dt.to_pytimedelta()

傳回一個原生 datetime.timedelta 物件的陣列。

Series.dt.total_seconds(*args,**kwargs)

傳回每個元素的總持續時間(以秒為單位)。

Series.dt.as_unit(*args, **kwargs)

字串處理#

Series.str 可用於存取系列的數值為字串,並對其套用多種方法。這些方法可透過 Series.str.<function/property> 來存取。

Series.str.capitalize()

將 Series/Index 中的字串轉換為首字母大寫。

Series.str.casefold()

將 Series/Index 中的字串轉換為小寫。

Series.str.cat([others,sep,na_rep,join])

使用指定的字元分隔符號串接 Series/Index 中的字串。

Series.str.center(width[,fillchar])

在 Series/Index 中的字串左右兩側填補字元。

Series.str.contains(pat[,case,flags,na,...])

測試 Series 或 Index 的字串中是否包含模式或正規表示式。

Series.str.count(pat[,flags])

計算 Series/Index 中每個字串中模式的出現次數。

Series.str.decode(編碼[, 錯誤])

使用指示的編碼解碼 Series/Index 中的字元串。

Series.str.encode(編碼[, 錯誤])

使用指示的編碼編碼 Series/Index 中的字元串。

Series.str.endswith(模式[, na])

測試每個字串元素的結尾是否與模式相符。

Series.str.extract(模式[, 標記, 展開])

將 regex 模式 中的擷取群組作為資料框中的欄位萃取出來。

Series.str.extractall(模式[, 標記])

將 regex 模式 中的擷取群組作為資料框中的欄位萃取出來。

Series.str.find(子字串[, 開始, 結束])

傳回 Series/Index 中每個字串的最低索引。

Series.str.findall(模式[, 標記])

在 Series/Index 中找出模式或正規表示式的所有出現。

Series.str.fullmatch(pat[, case, flags, na])

判斷每個字串是否完全符合正規表示式。

Series.str.get(i)

從每個元件中擷取指定位置或指定金鑰的元素。

Series.str.index(sub[, start, end])

傳回 Series/Index 中每個字串的最低索引。

Series.str.join(sep)

使用傳遞的分隔符號,串聯 Series/Index 中包含為元素的清單。

Series.str.len()

計算 Series/Index 中每個元素的長度。

Series.str.ljust(width[, fillchar])

在 Series/Index 中的字串右側填補。

Series.str.lower()

將 Series/Index 中的字串轉換成小寫。

Series.str.lstrip([to_strip])

移除開頭的字元。

Series.str.match(pat[, case, flags, na])

判斷每個字串是否以符合正規表達式的字元開頭。

Series.str.normalize(form)

傳回 Series/Index 中字串的 Unicode 正規形式。

Series.str.pad(width[, side, fillchar])

將 Series/Index 中的字串補齊至指定的寬度。

Series.str.partition([sep, expand])

在第一次出現 sep 的位置將字串分割。

Series.str.removeprefix(prefix)

從物件系列中移除字首。

Series.str.removesuffix(suffix)

從物件系列中移除字尾。

Series.str.repeat(repeats)

複製 Series 或 Index 中的每個字串。

Series.str.replace(pat, repl[, n, case, ...])

取代 Series/Index 中每個出現的模式/正規表示式。

Series.str.rfind(sub[, start, end])

傳回 Series/Index 中每個字串中最高的索引。

Series.str.rindex(sub[, start, end])

傳回 Series/Index 中每個字串中最高的索引。

Series.str.rjust(width[, fillchar])

在 Series/Index 中的字串左側填補。

Series.str.rpartition([sep, expand])

sep 最後出現的位置分割字串。

Series.str.rstrip([to_strip])

移除尾隨字元。

Series.str.slice([start, stop, step])

從 Series 或 Index 中每個元素切片子字串。

Series.str.slice_replace([start, stop, repl])

使用另一個值取代字串的特定位置切片。

Series.str.split([pat, n, expand, regex])

以指定的區隔符號/分隔符號分割字串。

Series.str.rsplit([pat, n, expand])

以指定的區隔符號/分隔符號分割字串。

Series.str.startswith(pat[, na])

測試每個字串元素的開頭是否與樣式相符。

Series.str.strip([to_strip])

移除開頭和結尾字元。

Series.str.swapcase()

將 Series/Index 中的字串轉換為大小寫互換。

Series.str.title()

將 Series/Index 中的字串轉換為標題大小寫。

Series.str.translate(table)

透過指定的對應表格將字串中的所有字元對應。

Series.str.upper()

將 Series/Index 中的字串轉換為大寫。

Series.str.wrap(width, **kwargs)

在指定的行寬處換行 Series/Index 中的字串。

Series.str.zfill(width)

透過在 Series/Index 中的字串前面加上 '0' 字元來填充。

Series.str.isalnum()

檢查每個字串中的所有字元是否為字母數字。

Series.str.isalpha()

檢查每個字串中的所有字元是否為字母。

Series.str.isdigit()

檢查每個字串中的所有字元是否為數字。

Series.str.isspace()

檢查每個字串中所有字元是否為空白。

Series.str.islower()

檢查每個字串中所有字元是否為小寫。

Series.str.isupper()

檢查每個字串中所有字元是否為大寫。

Series.str.istitle()

檢查每個字串中所有字元是否為標題大小寫。

Series.str.isnumeric()

檢查每個字串中所有字元是否為數字。

Series.str.isdecimal()

檢查每個字串中所有字元是否為十進制數字。

Series.str.get_dummies([sep])

傳回 Series 的虛擬/指標變數的 DataFrame。

類別存取器#

類別資料型態特定的方法和屬性可在 Series.cat 存取器中取得。

Series.cat.categories

此類別的類別。

Series.cat.ordered

類別是否具有順序關係。

Series.cat.codes

傳回包含代碼和索引的 Series。

Series.cat.rename_categories(*args, **kwargs)

重新命名類別。

Series.cat.reorder_categories(*args, **kwargs)

根據 new_categories 中的指定重新排序類別。

Series.cat.add_categories(*args, **kwargs)

新增類別。

Series.cat.remove_categories(*args, **kwargs)

移除指定的類別。

Series.cat.remove_unused_categories(*args, ...)

移除未使用的類別。

Series.cat.set_categories(*args, **kwargs)

將類別設定為指定的類別。

Series.cat.as_ordered(*args, **kwargs)

設定類別為已排序。

Series.cat.as_unordered(*args, **kwargs)

設定類別為未排序。

稀疏存取器#

稀疏資料型態的特定方法和屬性會在 Series.sparse 存取器中提供。

Series.sparse.npoints

fill_value 點的數量。

Series.sparse.density

fill_value 點的百分比,為小數。

Series.sparse.fill_value

data 中為 fill_value 的元素不會儲存。

Series.sparse.sp_values

包含非 fill_value 值的 ndarray。

Series.sparse.from_coo(A[, dense_index])

從 scipy.sparse.coo_matrix 建立具有稀疏值的 Series。

Series.sparse.to_coo([row_levels, ...])

從具有 MultiIndex 的 Series 建立 scipy.sparse.coo_matrix。

清單存取器#

Arrow 清單資料型態特定的方法和屬性會在 Series.list 存取器中提供。

Series.list.flatten()

扁平化清單值。

Series.list.len()

傳回 Series 中每個清單的長度。

Series.list.__getitem__(key)

索引或切片 Series 中的清單。

結構存取器#

Arrow 結構資料型態特定的方法和屬性會在 Series.struct 存取器中提供。

Series.struct.dtypes

傳回結構中每個子欄位的資料型態物件。

Series.struct.field(name_or_index)

將結構的子欄位萃取為 Series。

Series.struct.explode()

將結構的所有子欄位萃取為資料框。

旗標#

旗標是指 pandas 物件的屬性。資料集的屬性(例如記錄日期、存取的 URL 等)應儲存在 Series.attrs 中。

Flags(obj, *, allows_duplicate_labels)

適用於 pandas 物件的旗標。

元資料#

Series.attrs 是用於儲存此 Series 的全域元資料的字典。

警告

Series.attrs 被視為實驗性質,可能會在不預警的情況下變更。

Series.attrs

此資料集的全域屬性字典。

繪製#

Series.plot 既是可呼叫的方法,也是特定繪製方法的命名空間屬性,形式為 Series.plot.<kind>

Series.plot([kind, ax, figsize, ....])

Series 繪製存取器和方法

Series.plot.area([x, y, stacked])

繪製堆疊面積圖。

Series.plot.bar([x, y])

垂直長條圖。

Series.plot.barh([x, y])

建立水平長條圖。

Series.plot.box([by])

建立 DataFrame 欄位的箱型圖。

Series.plot.density([bw_method, ind])

使用高斯核產生核密度估計圖。

Series.plot.hist([by, bins])

繪製 DataFrame 欄位的直方圖。

Series.plot.kde([bw_method, ind])

使用高斯核產生核密度估計圖。

Series.plot.line([x, y])

將 Series 或 DataFrame 繪製成線條圖。

Series.plot.pie(**kwargs)

產生圓餅圖。

Series.hist([by, ax, grid, xlabelsize, ...])

使用 matplotlib 繪製輸入系列的直方圖。

序列化 / IO / 轉換#

Series.to_pickle(path, *[, compression, ...])

將物件序列化到檔案中。

Series.to_csv([path_or_buf, sep, na_rep, ...])

將物件寫入逗號分隔值 (csv) 檔案中。

Series.to_dict(*[, into])

將 Series 轉換為 {標籤 -> 值} 字典或類字典物件。

Series.to_excel(excel_writer, *[, ...])

將物件寫入 Excel 活頁簿中。

Series.to_frame([name])

將 Series 轉換為 DataFrame。

Series.to_xarray()

從 pandas 物件傳回 xarray 物件。

Series.to_hdf(path_or_buf, *, key[, mode, ...])

使用 HDFStore 將包含的資料寫入 HDF5 檔案中。

Series.to_sql(name, con, *[, schema, ...])

將儲存在 DataFrame 中的記錄寫入 SQL 資料庫。

Series.to_json([path_or_buf, orient, ...])

將物件轉換為 JSON 字串。

Series.to_string([buf, na_rep, ...])

呈現 Series 的字串表示形式。

Series.to_clipboard(*[, excel, sep])

將物件複製到系統剪貼簿。

Series.to_latex([buf, columns, header, ...])

將物件呈現為 LaTeX 表格、長表格或巢狀表格。

Series.to_markdown([buf, mode, index, ...])

以 Markdown 友善格式列印 Series。