3.0.0 中的新功能 (2026 年 1 月 21 日)#
這些是 pandas 3.0.0 中的更改。有關包括其他 pandas 版本在內的完整變更日誌,請參閱釋出說明。
注意
pandas 3.0 版本刪除了許多在先前版本中已棄用的功能(有關概述,請參閱下方)。建議在升級到 pandas 3.0 之前,首先升級到 pandas 2.3 並確保您的程式碼在沒有警告的情況下正常執行。
增強功能#
預設使用專用的字串資料型別#
歷史上,pandas 使用 NumPy 的 object 資料型別來表示字串列。這種表示方法存在許多問題:它不專門用於字串(object 型別的陣列可以儲存任何 Python 物件,而不僅僅是字串),而且通常效率不高(在效能和記憶體使用方面)。
從 pandas 3.0 開始,預設啟用專用的字串資料型別(底層由 PyArrow 支援,如果已安裝;否則,回退到由 NumPy object 型別支援)。這意味著 pandas 在建立 pandas 物件(例如在建構函式或 I/O 函式中)時,將開始將包含字串資料的列推斷為新的 str 資料型別。
舊行為
>>> ser = pd.Series(["a", "b"])
0 a
1 b
dtype: object
新行為
>>> ser = pd.Series(["a", "b"])
0 a
1 b
dtype: str
在這些場景中使用的字串資料型別在很大程度上將表現得像 NumPy object 一樣,包括缺失值語義和這些列上的通用操作。
新字串資料型別的主要特性
預設推斷字串資料(而不是 object 型別)
與
object型別不同,str型別只能包含字串(或缺失值)。(用非字串進行 setitem 會失敗)缺失值標記始終是
NaN(np.nan),並且遵循與其他預設資料型別相同的缺失值語義。
這些有意進行的更改可能導致破壞性後果,例如在檢查 .dtype 是否為 object 型別或檢查確切的缺失值標記時。有關行為更改的更多詳細資訊以及如何使您的程式碼適應新的預設設定,請參閱新字串資料型別遷移指南(pandas 3.0)。
Copy-on-Write 的一致複製/檢視行為#
pandas 3.0 中的新“Copy-on-Write”行為在 pandas 處理複製和檢視的方式上帶來了行為上的改變。變更摘要
任何索引操作(以任何方式子集化 DataFrame 或 Series,即包括將 DataFrame 列作為 Series 訪問)或返回新的 DataFrame 或 Series 的任何方法的結果,在使用者 API 方面始終表現得像是複製。
因此,如果您想修改一個物件(DataFrame 或 Series),唯一的方法是直接修改該物件本身。
此更改的主要目標是使使用者 API 更加一致和可預測。現在有一個明確的規則:任何子集或返回的 Series/DataFrame 始終表現為原始物件的副本,因此永遠不會修改原始物件(在 pandas 3.0 之前,派生物件是副本還是檢視取決於執行的確切操作,這常常令人困惑)。
由於每個索引步驟現在都表現為副本,這也意味著“鏈式賦值”(透過多個 setitem 步驟更新 DataFrame)將停止工作。由於這現在始終無效,因此移除了 SettingWithCopyWarning,並且不再需要防禦性地呼叫 .copy() 來抑制警告。
新行為語義在關於 Copy-on-Write 的使用者指南中有更詳細的解釋。
次要目標是透過避免不必要的複製來提高效能。如上所述,從索引操作或方法返回的每個新的 DataFrame 或 Series 都表現為副本,但在底層,pandas 會盡可能使用檢視,僅在需要保證“表現為副本”的行為時才複製(這是實際使用的“Copy-on-Write”機制作為實現細節)。
上述某些行為更改是 pandas 3.0 中的破壞性更改。升級到 pandas 3.0 時,建議首先升級到 pandas 2.3,以獲取這些更改子集的一些棄用警告。遷移指南更詳細地解釋了升級過程。
設定 mode.copy_on_write 選項不再有任何影響。該選項已被棄用,將在 pandas 4.0 中刪除。
初步支援使用 pd.col() 語法建立表示式#
此版本引入了 col(),用於按名稱引用 DataFrame 列並構建表示式。
這可以用作一種簡化的語法,用於建立可呼叫物件,供 DataFrame.assign() 等方法使用。實際上,以前需要使用 lambda 函式的地方,現在可以使用 pd.col() 代替。
例如,如果您有一個 DataFrame
In [1]: df = pd.DataFrame({'a': [1, 1, 2], 'b': [4, 5, 6]})
並且您想透過對 'a' 和 'b' 求和來建立一個新列 'c',那麼與使用
In [2]: df.assign(c = lambda df: df['a'] + df['b'])
Out[2]:
a b c
0 1 4 5
1 1 5 6
2 2 6 8
您現在可以這樣寫
In [3]: df.assign(c = pd.col('a') + pd.col('b'))
Out[3]:
a b c
0 1 4 5
1 1 5 6
2 2 6 8
col() 返回的表示式物件支援所有標準運算子(如 +、-、*、/ 等)以及所有 Series 方法和名稱空間(如 pd.col("name").sum()、pd.col("name").str.upper() 等)。
目前,pd.col() 語法可以用於接受一個可呼叫物件(該物件將呼叫它的 DataFrame 作為第一個引數並返回一個 Series)的任何地方,例如 lambda df: df[col_name]。這包括 DataFrame.assign()、DataFrame.loc(),以及 getitem/setitem。
預計在未來的版本中,pd.col() 的支援將擴充套件到更多方法。
支援 Arrow PyCapsule 介面#
Arrow C 資料介面允許透過 Arrow 格式在不同 DataFrame 庫之間移動資料,並且儘可能設計為零複製。在 Python 中,該介面透過 Arrow PyCapsule 協議公開。
DataFrame 和 Series 現在支援 Arrow PyCapsule 介面,用於資料的匯出和匯入(GH 56587,GH 63208,GH 59518,GH 59631)。
添加了專用的 DataFrame.from_arrow() 和 Series.from_arrow() 方法,用於透過該介面將任何 Arrow 相容的資料物件匯入 pandas 物件。
對於匯出,DataFrame 和 Series 實現 C 流介面(__arrow_c_stream__)方法。
這些方法目前依賴 pyarrow 將表格物件轉換為 Arrow 格式或從 Arrow 格式轉換為 pandas。
更新的棄用策略#
pandas 3.0.0 更新了棄用策略,使用新的 3 階段策略來明確將發出哪些棄用警告:首先使用 DeprecationWarning,然後在下一個主要版本之前的最後一個次要版本中切換到 FutureWarning 以獲得更廣泛的可見性,然後在主要版本中刪除已棄用的功能。這樣做的目的是為下游包提供更多時間來適應 pandas 的棄用,這應該會減少使用者從非自己程式碼中收到的警告數量。有關更多詳細資訊,請參閱PDEP 17。
pandas 中即將發生的所有更改的警告都將具有基類 pandas.errors.PandasChangeWarning。使用者還可以使用以下子類來控制警告。
pandas.errors.Pandas4Warning:將在 pandas 4.0 中強制執行的警告。pandas.errors.Pandas5Warning:將在 pandas 5.0 中強制執行的警告。pandas.errors.PandasPendingDeprecationWarning:所有發出PendingDeprecationWarning的警告的基類,無論它們將在哪個版本中強制執行。pandas.errors.PandasDeprecationWarning:所有發出DeprecationWarning的警告的基類,無論它們將在哪個版本中強制執行。pandas.errors.PandasFutureWarning:所有發出FutureWarning的警告的基類,無論它們將在哪個版本中強制執行。
在 3.x 中使用 pandas.errors.Pandas4Warning 新增的棄用將最初繼承自 pandas.errors.PandasDeprecationWarning。在 3.x 系列的最後一個次要版本中,這些棄用將切換為繼承自 pandas.errors.PandasFutureWarning,以獲得更廣泛的可見性。
其他增強功能#
I/O
改進了
errors.DtypeWarning,在檢測到混合資料型別時包含列名(GH 58174)在
DataFrame.to_excel()中,merge_cells引數現在接受值"columns",僅合併MultiIndex列標題單元格(GH 35384)DataFrame.to_excel()有一個新的autofilter引數,用於為所有列新增自動過濾器(GH 61194)當單元格中的字元數超過 Excel 的 32767 個字元限制時,
DataFrame.to_excel()現在會引發UserWarning(GH 56954)read_parquet()接受to_pandas_kwargs,它會被轉發到pyarrow.Table.to_pandas(),這使得可以傳遞額外的關鍵字引數來自定義轉換為 pandas 的過程,例如使用maps_as_pydicts將 Parquet 對映資料型別讀取為 Python 字典(GH 56842)read_spss()現在支援將 kwargs 傳遞給pyreadstat(GH 56356)read_stata()現在返回的datetime64解析度能更好地匹配 Stata 格式中原生儲存的解析度(GH 55642)DataFrame.to_csv()和Series.to_csv()現在除了%格式字串和可呼叫物件之外,還支援 f-string(例如"{:.6f}")用於float_format引數(GH 49580)DataFrame.to_json()現在將Decimal編碼為字串而不是浮點數(GH 60698)在
DataFrame.to_sql()的if_exists引數中添加了"delete_rows"選項,在插入資料之前刪除表中的所有記錄(GH 37210)。使用新的
read_iceberg()和DataFrame.to_iceberg()函式,添加了與 Apache Iceberg 表進行讀寫支援(GH 61383)SQL I/O 期間發生的錯誤現在將丟擲通用
DatabaseError,而不是來自底層驅動程式管理器庫的原始 Exception 型別(GH 60748)恢復了對讀取 Stata 104 格式的支援,並啟用了對 103 格式 dta 檔案的讀取(GH 58554)
支援讀取 Stata 102 格式(Stata 1)dta 檔案(GH 58978)
支援讀取 Stata 110 格式(Stata 7)dta 檔案(GH 47176)
支援從 Stata 108 格式(Stata 6)及更早的檔案中讀取值標籤(GH 58154)
Groupby/resample/rolling
pandas.NamedAgg現在支援將*args和**kwargs傳遞給aggfunc的呼叫(GH 58283)DataFrameGroupBy和SeriesGroupBy方法sum、mean、median、prod、min、max、std、var和sem現在接受skipna引數(GH 15675)DataFrameGroupBy.transform()、SeriesGroupBy.transform()、DataFrameGroupBy.agg()、SeriesGroupBy.agg()、RollingGroupby.apply()、ExpandingGroupby.apply()、Rolling.apply()、Expanding.apply()、DataFrame.apply()(使用engine="numba")現在支援作為 kwargs 傳遞的位置引數(GH 58995)DataFrameGroupBy.transform()、SeriesGroupBy.transform()、DataFrameGroupBy.agg()、SeriesGroupBy.agg()、SeriesGroupBy.apply()、DataFrameGroupBy.apply()現在支援kurt(GH 40139)Rolling.aggregate()、Expanding.aggregate()和ExponentialMovingWindow.aggregate()現在透過**kwargs接受NamedAgg聚合(GH 28333)添加了
Rolling.first()、Rolling.last()、Expanding.first()和Expanding.last()(GH 33155)
Reshaping
pandas.merge()會將attrs屬性傳播到結果,如果所有輸入具有相同的attrs,這與pandas.concat()迄今為止的情況相同。pandas.merge()現在會驗證how引數的輸入(合併型別)(GH 59435)pandas.merge(),DataFrame.merge()和DataFrame.join()現在支援反連線(left_anti和right_anti)在how引數中(GH 42916)DataFrame.pivot_table()和pivot_table()現在允許透過**kwargs將關鍵字引數傳遞給aggfunc(GH 57884)pandas.concat()當ignore_index=True且keys不為None時將引發ValueError(GH 59274)
Missing
DataFrame.fillna()和Series.fillna()現在可以接受value=None;對於非物件 dtype,將使用相應的 NA 值(GH 57723)在
DataFrame.fillna()中,添加了對axis=1與dict或Series引數的支援(GH 4514)
數值
當
DataFrame.agg()使用axis=1和一個會重新標記結果索引的func呼叫時,現在會引發NotImplementedError(GH 58807)。DataFrame.corrwith()現在接受min_periods作為可選引數,與DataFrame.corr()和Series.corr()相同(GH 9490)DataFrame.cummin(),DataFrame.cummax(),DataFrame.cumprod()和DataFrame.cumsum()方法現在有一個numeric_only引數(GH 53072)DataFrame.ewm()現在在提供times時允許adjust=False(GH 54328)Series.cummin()和Series.cummax()現在支援CategoricalDtype(GH 52335)Series.map()現在可以接受 kwargs 來傳遞給 func(GH 59814)Series.nlargest()在內部使用穩定排序,在相等的情況下會保留原始順序(GH 55767)Series.round()現在支援物件 dtype,前提是底層 Python 物件實現了__round__(GH 63444)支援將
Iterable[Hashable]輸入傳遞給DataFrame.drop_duplicates()(GH 59237)
字串
Series.str.get_dummies()現在接受dtype引數來指定結果 DataFrame 的 dtype(GH 47872)允許透過
pat引數將字典傳遞給Series.str.replace()(GH 51748)
Datetimelike
Easter獲得了一個新的建構函式引數method,它指定了用於計算復活節的方法,例如東正教復活節(GH 61665)Holiday建構函式引數days_of_week在型別不是None或tuple時將引發ValueError(GH 61658)Holiday獲得了建構函式引數和欄位exclude_dates,用於從自定義假日日曆中排除特定的日期時間(GH 54382)添加了半年度偏移類
HalfYearBegin、HalfYearEnd、BHalfYearBegin和BHalfYearEnd(GH 60928)改進了偏移量別名的棄用訊息(GH 60820)
將兩個
DateOffset物件相乘現在將引發TypeError而不是RecursionError(GH 59442)
索引
DataFrame.iloc()和Series.iloc()在__getitem__中現在支援布林掩碼,以實現更一致的索引行為(GH 60994)Index.get_loc()現在也接受tuple的子類作為鍵(GH 57922)
Styler / 輸出格式
Styler.set_tooltips()提供了一種替代方法來儲存工具提示,透過使用 td 元素的 title 屬性。(GH 56981)添加了
Styler.to_typst(),用於將 Styler 物件寫入 Typst 格式的檔案、緩衝區或字串(GH 57617)Styler.format_index_names()現在可用於格式化索引和列名(GH 48936 和 GH 47489)pandas 物件中的
frozenset元素現在可以本機列印(GH 60690)
型別提示
pandas.api.typing.FrozenList可用於對MultiIndex.names、MultiIndex.codes和MultiIndex.levels的輸出進行型別提示(GH 58237)pandas.api.typing.NoDefault可用於對no_default進行型別提示(GH 60696)pandas.api.typing.SASReader可用於對read_sas()的輸出進行型別提示(GH 55689)許多類型別名現在已在新子模組
pandas.api.typing.aliases中公開(GH 55231)
繪圖
Series.plot()現在可以正確處理餅圖的ylabel引數,從而允許對 y 軸標籤進行顯式控制(GH 58239)在
DataFrame.plot.kde()中為 PDF 估計添加了缺失的weights引數(GH 59337)DataFrame.plot.scatter()引數c現在接受一個字串列,其中具有相同字串的行會被著色相同(GH 16827 和 GH 16485)
ExtensionArray
ArrowDtype現在支援pyarrow.JsonType(GH 60958)使用 numpy 可空 dtype 的
Series.rank()和DataFrame.rank()會保留NA值,並在適當的時候返回UInt64dtype,而不是將NA轉換為float64dtype 的NaN(GH 62043)改進了
DataFrame.where()和DataFrame.mask()在使用ExtensionDtypeother時的結果 dtype(GH 62038)
其他
set_option()現在接受一個選項字典,從而簡化了多個設定的同時配置(GH 61093)DataFrame.apply()支援使用第三方執行引擎,如 Bodo.ai JIT 編譯器(GH 60668)Series.map()現在接受一個engine引數,以允許使用第三方執行引擎進行執行(GH 61125)支援將
Series輸入傳遞給json_normalize(),並保留Index(GH 51452)使用者可以透過將選項
mode.performance_warnings設定為False來全域性停用任何PerformanceWarning(GH 56920)
打包
重要的 bug 修復#
這些 bug 修復可能帶來行為上的顯著變化。
改進了 groupby 中 observed=False 的行為#
透過改進對未觀察到的組的處理,修復了許多錯誤。本節中的所有說明都同樣影響 SeriesGroupBy。(GH 55738)
在 pandas 的先前版本中,使用 DataFrameGroupBy.apply() 或 DataFrameGroupBy.agg() 進行單次分組會將未觀察到的組傳遞給提供的函式,從而正確得到下方的 0。
In [4]: df = pd.DataFrame(
...: {
...: "key1": pd.Categorical(list("aabb"), categories=list("abc")),
...: "key2": [1, 1, 1, 2],
...: "values": [1, 2, 3, 4],
...: }
...: )
...:
In [5]: df
Out[5]:
key1 key2 values
0 a 1 1
1 a 1 2
2 b 1 3
3 b 2 4
In [6]: gb = df.groupby("key1", observed=False)
In [7]: gb[["values"]].apply(lambda x: x.sum())
Out[7]:
values
key1
a 3
b 7
c 0
然而,在使用多重分組時,情況並非如此,會導致下方的 NaN。
In [1]: gb = df.groupby(["key1", "key2"], observed=False)
In [2]: gb[["values"]].apply(lambda x: x.sum())
Out[2]:
values
key1 key2
a 1 3.0
2 NaN
b 1 3.0
2 4.0
c 1 NaN
2 NaN
現在,使用多重分組也會將未觀察到的組傳遞給提供的函式。
In [8]: gb = df.groupby(["key1", "key2"], observed=False)
In [9]: gb[["values"]].apply(lambda x: x.sum())
Out[9]:
values
key1 key2
a 1 3
2 0
b 1 3
2 4
c 1 0
2 0
同樣
在 pandas 的先前版本中,方法
DataFrameGroupBy.sum()對於未觀察到的組會產生0,但DataFrameGroupBy.prod()、DataFrameGroupBy.all()和DataFrameGroupBy.any()都會產生 NA 值。現在這些方法分別產生1、True和False。DataFrameGroupBy.groups()沒有包含未觀察到的組,現在包含了。
這些改進也修復了 groupby 中的某些錯誤
當存在多重分組、未觀察到的組且
as_index=False時,DataFrameGroupBy.agg()會失敗(GH 36698)當
sort=False時,DataFrameGroupBy.groups()會對組進行排序;現在它們將按照觀察到的順序出現(GH 56966)當存在多重分組、未觀察到的組且
as_index=False時,DataFrameGroupBy.nunique()會失敗(GH 52848)當存在多重分組、未觀察到的組且存在非數字資料時,
DataFrameGroupBy.sum()的值不正確(GH 43891)當使用部分分類和部分非分類分組以及
observed=False時,DataFrameGroupBy.value_counts()會產生不正確的結果(GH 56016)
向後不相容的 API 更改#
日期時間/時間差解析度推斷#
在 pandas 3.0 之前,每當將字串序列、標準庫 datetime 物件、np.datetime64 物件或整數轉換為 datetime64 / timedelta64 dtype 時,這總是會導致納秒解析度(或因超出範圍而引發錯誤)。現在,它會對適當的解析度(也稱為 unit)進行推斷,用於輸出 dtype。這會影響通用建構函式(Series、DataFrame、Index、DatetimeIndex)以及特定的轉換或建立函式(to_datetime()、to_timedelta()、date_range()、timedelta_range()、Timestamp、Timedelta)。
各種輸入型別的通用規則
解析字串時的預設新解析度為微秒,當字串的精度需要時,會回退到納秒。
對於標準庫
datetime物件(即微秒)或np.datetime64/np.timedelta64物件(即單位,最多支援到秒到納秒的範圍),輸入的解析度會被保留。對於整數輸入,解析整數值的方式被用作結果解析度(或被限制在支援的秒到納秒範圍內)。
例如,以下在以前總是會給出納秒解析度,但現在會推斷
# parsing strings
In [10]: print(pd.to_datetime(["2024-03-22 11:36"]).dtype)
datetime64[us]
# converting integers
In [11]: print(pd.to_datetime([0], unit="s").dtype)
datetime64[s]
# converting stdlib datetime object
In [12]: dt = pd.Timestamp("2024-03-22 11:36").to_pydatetime()
In [13]: print(pd.to_datetime([dt]).dtype)
datetime64[us]
# the same when inferring a datetime dtype in the generic constructors
In [14]: print(pd.Series([dt]).dtype)
datetime64[us]
# converting numpy objects
In [15]: print(pd.Series([np.datetime64("2024-03-22", "ms")]).dtype)
datetime64[ms]
當傳入一系列 np.datetime64 物件時,也會有類似的情況,傳入物件的解析度將被保留(或者對於低於秒的解析度,將使用秒解析度)。
解析字串時,預設現在是微秒(這也影響從文字檔案讀取的 I/O 方法,例如 read_csv() 和 read_json())。除非字串具有納秒精度,在這種情況下將使用納秒解析度。
In [16]: print(pd.to_datetime(["2024-03-22 11:43:01.123"]).dtype)
datetime64[us]
In [17]: print(pd.to_datetime(["2024-03-22 11:43:01.123456"]).dtype)
datetime64[us]
In [18]: print(pd.to_datetime(["2024-03-22 11:43:01.123456789"]).dtype)
datetime64[ns]
對於帶有字串輸入的 Timestamp 建構函式來說,這也有一個變化,在版本 2.x.y 中,這可能會給出秒或毫秒單位(GH 52653)。
警告
許多使用者現在將在他們以前得到“datetime64[ns]”資料型別的情況下得到“datetime64[us]”資料型別。對於大多數用例,他們應該不會注意到差異。一個大的例外是將它們轉換為整數,這將得到小 1000 倍的整數。
當將日期時間類資料轉換為整數時,建議避免使用 astype("int64") 以使程式碼不依賴於確切的單位,或者在轉換之前確保所需的單位,使用 as_unit()。
有關更多詳細資訊,請參閱 從時間戳到 epoch。
concat() 不再忽略 sort 引數,當所有物件都有 DatetimeIndex 時#
當傳遞給 concat() 的所有物件都具有 DatetimeIndex 時,傳遞 sort=False 現在將導致非連線軸不排序。以前,即使傳遞了 sort=False,結果也會沿著非連線軸排序。(GH 57335)
如果您不指定 sort 引數,pandas 將繼續返回排序結果,但此行為已被棄用,您將收到警告。為了減少對使用者的干擾,pandas 會檢查不排序是否會影響結果,並且僅在會影響時發出警告。此檢查可能很耗時,使用者可以透過顯式指定 sort=True 或 sort=False 來跳過此檢查。
此棄用也可能影響 pandas 對 concat() 的內部使用。以下是 concat() 對 DatetimeIndex 進行排序但不對其他索引進行排序的情況,這些情況被視為錯誤並已按如下方式修復。但仍有可能遺漏一些。為了謹慎起見,pandas 未 在我們認為行為不應改變的任何內部呼叫中新增 sort=False。如果我們遺漏了什麼,使用者將不會體驗到行為改變,但他們將收到關於 concat() 的警告,儘管他們沒有直接呼叫此函式。如果發生這種情況,我們要求使用者提出問題,以便我們解決任何潛在的行為變更。
In [19]: idx1 = pd.date_range("2025-01-02", periods=3, freq="h")
In [20]: df1 = pd.DataFrame({"a": [1, 2, 3]}, index=idx1)
In [21]: df1
Out[21]:
a
2025-01-02 00:00:00 1
2025-01-02 01:00:00 2
2025-01-02 02:00:00 3
In [22]: idx2 = pd.date_range("2025-01-01", periods=3, freq="h")
In [23]: df2 = pd.DataFrame({"b": [1, 2, 3]}, index=idx2)
In [24]: df2
Out[24]:
b
2025-01-01 00:00:00 1
2025-01-01 01:00:00 2
2025-01-01 02:00:00 3
舊行為
In [3]: pd.concat([df1, df2], axis=1, sort=False)
Out[3]:
a b
2025-01-01 00:00:00 NaN 1.0
2025-01-01 01:00:00 NaN 2.0
2025-01-01 02:00:00 NaN 3.0
2025-01-02 00:00:00 1.0 NaN
2025-01-02 01:00:00 2.0 NaN
2025-01-02 02:00:00 3.0 NaN
新行為
In [25]: pd.concat([df1, df2], axis=1, sort=False)
Out[25]:
a b
2025-01-02 00:00:00 1.0 NaN
2025-01-02 01:00:00 2.0 NaN
2025-01-02 02:00:00 3.0 NaN
2025-01-01 00:00:00 NaN 1.0
2025-01-01 01:00:00 NaN 2.0
2025-01-01 02:00:00 NaN 3.0
在此版本中修復的 pandas 內部使用 concat() 導致不一致排序的情況如下。
Series.apply()和DataFrame.apply()使用列表類或字典類func引數。Series.shift()、DataFrame.shift()、SeriesGroupBy.shift()、DataFrameGroupBy.shift()使用長度大於 1 的periods引數列表。DataFrame.join()使用other為一個或多個 Series 或 DataFrames 的列表,並且how="inner"、how="left"或how="right"。Series.str.cat()使用others作為 Series 或 DataFrame。
在 DataFrame.value_counts() 和 DataFrameGroupBy.value_counts() 中,當 sort=False 時行為已更改#
在 pandas 的先前版本中,DataFrame.value_counts() 和 sort=False 會按行標籤對結果進行排序(如文件所述)。這不符合直覺,並且與 Series.value_counts() 保持輸入順序的行為不一致。現在 DataFrame.value_counts() 將保持輸入順序。(GH 59745)
In [26]: df = pd.DataFrame(
....: {
....: "a": [2, 2, 2, 2, 1, 1, 1, 1],
....: "b": [2, 1, 3, 1, 2, 3, 1, 1],
....: }
....: )
....:
In [27]: df
Out[27]:
a b
0 2 2
1 2 1
2 2 3
3 2 1
4 1 2
5 1 3
6 1 1
7 1 1
舊行為
In [3]: df.value_counts(sort=False)
Out[3]:
a b
1 1 2
2 1
3 1
2 1 2
2 1
3 1
Name: count, dtype: int64
新行為
In [28]: df.value_counts(sort=False)
Out[28]:
a b
2 2 1
1 2
3 1
1 2 1
3 1
1 2
Name: count, dtype: int64
此更改也適用於 DataFrameGroupBy.value_counts()。這裡有兩種排序選項:一種是傳遞給 DataFrame.groupby() 的 sort,另一種是直接傳遞給 DataFrameGroupBy.value_counts()。前者決定是否對組進行排序,後者決定是否對計數進行排序。所有非分組列將在組內保持輸入順序。
舊行為
In [5]: df.groupby("a", sort=True).value_counts(sort=False)
Out[5]:
a b
1 1 2
2 1
3 1
2 1 2
2 1
3 1
dtype: int64
新行為
In [29]: df.groupby("a", sort=True).value_counts(sort=False)
Out[29]:
a b
1 2 1
3 1
1 2
2 2 1
3 1
1 2
Name: count, dtype: int64
改變了 pd.offsets.Day 的行為,使其始終表示日曆日#
在 pandas 的先前版本中,offsets.Day 表示固定的 24 小時跨度,不考慮夏令時轉換。它現在始終表現為日曆日,在夏令時轉換期間保留一天中的時間。(GH 61985)
舊行為
In [5]: ts = pd.Timestamp("2025-03-08 08:00", tz="US/Eastern")
In [6]: ts + pd.offsets.Day(1)
Out[3]: Timestamp('2025-03-09 09:00:00-0400', tz='US/Eastern')
新行為
In [30]: ts = pd.Timestamp("2025-03-08 08:00", tz="US/Eastern")
In [31]: ts + pd.offsets.Day(1)
Out[31]: Timestamp('2025-03-09 08:00:00-0400', tz='US/Eastern')
此更改修復了 date_range() 中的一個長期存在的錯誤(GH 51716,GH 35388),但作為附帶結果導致了幾個小的行為差異。
pd.offsets.Day(n)不再與pd.offsets.Hour(24*n)相等。offsets.Day不再支援除法。tseries.frequencies.to_offset()在Timedelta物件上,在以前返回Day物件的情況下,現在返回offsets.Hour物件。向帶有
Dayfreq的時區感知DatetimeIndex新增或減去一個標量,不再保留該freq屬性。向時區感知
Timestamp或類似日期時間物件新增或減去一個Day偏移量,可能會導致歧義或不存在的時間,這將引發錯誤。
改變了 pyarrow 和 numpy 可空浮點 dtype 中 NaN 值的處理方式#
以前,在處理可空 dtype(例如 Float64Dtype 或 int64[pyarrow])時,NaN 在某些情況下被視為與 NA 可互換,但在其他情況下則不然。這是為了便於採用,但導致了一些混淆(GH 32265)。在 3.0 中,這種行為透過預設情況下在所有情況下將 NaN 視為等同於 NA 來實現一致性。
預設情況下,NaN 可以傳遞給建構函式、__setitem__、__contains__,並且將被視為與 NA 相同。使用者唯一會看到的變化是,以前引入 NaN 條目的算術和 np.ufunc 操作現在會產生 NA 條目。
舊行為
# NaN in input gets converted to NA
In [1]: ser = pd.Series([0, np.nan], dtype=pd.Float64Dtype())
In [2]: ser
Out[2]:
0 0.0
1 <NA>
dtype: Float64
# NaN produced by arithmetic (0/0) remained NaN
In [3]: ser / 0
Out[3]:
0 NaN
1 <NA>
dtype: Float64
# the NaN value is not considered as missing
In [4]: (ser / 0).isna()
Out[4]:
0 False
1 True
dtype: bool
新行為
In [32]: ser = pd.Series([0, np.nan], dtype=pd.Float64Dtype())
In [33]: ser
Out[33]:
0 0.0
1 <NA>
dtype: Float64
In [34]: ser / 0
Out[34]:
0 <NA>
1 <NA>
dtype: Float64
In [35]: (ser / 0).isna()
Out[35]:
0 True
1 True
dtype: bool
將來,打算將 NaN 和 NA 視為不同的值,並且在 3.0 中透過 pd.options.future.distinguish_nan_and_na 選項添加了一個控制此行為的選項。啟用後,NaN 始終被視為不同,特別是作為浮點值。因此,它不能與整數 dtype 一起使用。
舊行為
In [2]: ser = pd.Series([1, np.nan], dtype=pd.Float64Dtype())
In [3]: ser[1]
Out[3]: <NA>
新行為
In [36]: with pd.option_context("future.distinguish_nan_and_na", True):
....: ser = pd.Series([1, np.nan], dtype=pd.Float64Dtype())
....: print(ser[1])
....:
nan
如果我們為後者示例中的 dtype 傳遞了 pd.Int64Dtype() 或 "int64[pyarrow]",這將引發錯誤,因為浮點 NaN 不能由整數 dtype 儲存。
當啟用 "future.distinguish_nan_and_na" 時,ser.to_numpy()(以及 frame.values 和 np.asarray(obj))將在存在 NA 條目時轉換為 object dtype,而以前它們會強制轉換為 NaN。要保留浮點 numpy dtype,請顯式將 na_value=np.nan 傳遞給 Series.to_numpy()。
請注意,該選項是實驗性的,可能在未來的版本中發生變化。
__module__ 屬性現在指向公共模組#
公共 API 中函式和類的 __module__ 屬性已更新,以指向訪問該物件的首選公共模組,而不是該物件碰巧定義的模組(GH 55178)。
這在 Python 控制檯中產生更具資訊量的類顯示,例如,不是 <class 'pandas.core.frame.DataFrame'>,而是看到 <class 'pandas.DataFrame'>,以及在 IPython 等互動式工具中,例如,不是 <function pandas.io.parsers.readers.read_csv(...)>,而是看到 <function pandas.read_csv(...)>。
這可能會破壞依賴於先前 __module__ 值的程式碼(例如,檢查 DataFrame 物件 type() 的 doctest)。
提高了 Python 的最低版本要求#
pandas 3.0.0 支援 Python 3.11 及更高版本。
提高了依賴項的最低版本#
一些最低支援的依賴版本已更新。以下必需的依賴項已更新:
包 |
新最低版本 |
|---|---|
numpy |
1.26.0 |
對於可選庫,一般建議使用最新版本。下表列出了在 pandas 開發過程中始終進行測試的每個庫的最低版本。低於最低測試版本的可選庫可能仍然有效,但未被視為受支援。
包 |
新最低版本 |
|---|---|
adbc-driver-postgresql |
1.2.0 |
adbc-driver-sqlite |
1.2.0 |
mypy (dev) |
1.9.0 |
beautifulsoup4 |
4.12.3 |
bottleneck |
1.4.2 |
fastparquet |
2024.11.0 |
fsspec |
2024.10.0 |
hypothesis |
6.116.0 |
gcsfs |
2024.10.0 |
Jinja2 |
3.1.5 |
lxml |
5.3.0 |
Jinja2 |
3.1.3 |
matplotlib |
3.9.3 |
numba |
0.60.0 |
numexpr |
2.10.2 |
qtpy |
2.4.2 |
openpyxl |
3.1.5 |
psycopg2 |
2.9.10 |
pyarrow |
13.0.0 |
pymysql |
1.1.1 |
pyreadstat |
1.2.8 |
pytables |
3.10.1 |
python-calamine |
0.3.0 |
pytz |
2024.2 |
s3fs |
2024.10.0 |
SciPy |
1.14.1 |
sqlalchemy |
2.0.36 |
xarray |
2024.10.0 |
xlsxwriter |
3.2.0 |
zstandard |
0.23.0 |
有關更多資訊,請參閱Dependencies和Optional dependencies。
pytz 現在是可選依賴項#
pandas 現在將標準庫中的 zoneinfo 用作預設時區實現,用於將時區字串傳遞給各種方法。(GH 34916)
舊行為
In [1]: ts = pd.Timestamp(2024, 1, 1).tz_localize("US/Pacific")
In [2]: ts.tz
<DstTzInfo 'US/Pacific' LMT-1 day, 16:07:00 STD>
新行為
In [37]: ts = pd.Timestamp(2024, 1, 1).tz_localize("US/Pacific")
In [38]: ts.tz
Out[38]: zoneinfo.ZoneInfo(key='US/Pacific')
pytz 時區物件在直接傳遞時仍然受支援,但它們將不再預設從字串輸入返回。此外,pytz 不再是 pandas 的必需依賴項,但可以透過 pip extra pip install pandas[timezone] 安裝。
此外,pandas 不再為導致歧義或不存在的時間的時區操作引發 pytz 異常。這些情況現在將引發 ValueError。
其他 API 更改#
IO 方法中不再明確支援第三方
py.path物件。請改用pathlib.Path物件(GH 57091)。read_table()的parse_dates引數預設值為None,以提高與read_csv()的一致性(GH 57476)。Period.to_timestamp()和PeriodIndex.to_timestamp()現在在可能的情況下返回微秒單位的物件,在其他情況下返回納秒單位的物件。這會影響Period.end_time()和PeriodIndex.end_time()的實際值(GH 56164)。所有繼承自內建
tuple的類(包括使用collections.namedtuple()建立的型別)在索引操作中現在被視為內建tuple進行雜湊處理和比較(GH 57922)。將
dtype作為必需引數新增到ExtensionArray._from_sequence_of_strings()(GH 56519)。將
Series輸入傳遞給json_normalize()現在將保留Series的Index,以前的輸出有一個新的RangeIndex(GH 51452)。不再明確支援使用 Python 2 建立的 Pickle 和 HDF(
.h5)檔案(GH 57387)。不再支援來自 pandas 版本低於
1.0.0的 pickled 物件(GH 57155)。移除了
Index.sort(),該方法總是引發TypeError。此屬性未定義,將引發AttributeError(GH 59283)。從
MultiIndex建構函式中移除了未使用的dtype引數(GH 60962)。更新了
DataFrame.to_excel(),使輸出的電子表格沒有樣式。仍然可以使用Styler.to_excel()進行自定義樣式設定(GH 54154)。在
testing.assert_series_equal()中比較索引時,如果Index的資料型別是整數型別,check_exact預設值為 True。(GH 57386)。索引集合操作(如並集或交集)在確定結果索引的資料型別時,將忽略空
RangeIndex或物件資料型別的空Index的資料型別(GH 60797)。IncompatibleFrequency現在繼承自TypeError而不是ValueError。因此,頻率不匹配的連線現在會像其他不可比較的連線一樣強制轉換為物件,並且頻率不匹配的索引之間的算術運算會進行對齊(GH 55782)。Series的“flex”方法(如Series.add())不再允許為other引數傳遞DataFrame;請改用 DataFrame 的反向方法(GH 46179)。date_range()和timedelta_range()不再預設unit="ns",而是會從start、end和freq引數推斷單位。要覆蓋這些,請顯式指定所需的unit(GH 59031)。CategoricalIndex.append()不再嘗試將不同資料型別的索引強制轉換為呼叫者的資料型別(GH 41626)。ExtensionDtype.construct_array_type()現在是普通方法,而不是classmethod(GH 58663)。Series、Index或ExtensionArray與list之間的算術運算現在將該列表一致地包裝在等同於Series(my_list).array的陣列中。要進行任何其他型別的推斷或轉換,請在操作之前顯式進行(GH 62552)。Index和Series之間的比較操作現在始終返回Series,無論哪個物件在左邊還是右邊(GH 36759)。NumPy 函式(如
np.isinf),當在Index物件上呼叫時返回布林 dtype,現在返回布林資料型別的Index而不是np.ndarray(GH 52676)。可以就地操作的方法(
replace()、fillna()、ffill()、bfill()、interpolate()、where()、mask()、clip())在inplace=True時,現在返回修改後的 DataFrame 或 Series(self),而不是None(GH 63207)。所有 Index 建構函式現在預設複製
numpy.ndarray和ExtensionArray輸入,當copy=None時,這與Series的行為一致(GH 63388)。
棄用#
Copy 關鍵字#
以下方法的 copy 關鍵字引數已被棄用,並將在未來版本中刪除。(GH 57347)
DataFrame.merge()/pd.merge()
Copy-on-Write 使用延遲複製機制,該機制會推遲資料複製,直到需要時為止。使用 .copy 觸發即時複製。從 3.0 版本開始,copy 關鍵字沒有效果,因此可以安全地從程式碼中刪除它。
其他棄用項#
已棄用
core.internals.api.make_block(),請使用公共 API(GH 56815)。已棄用
DataFrameGroupby.corrwith()(GH 57158)。已棄用
Timestamp.utcfromtimestamp(),請使用Timestamp.fromtimestamp(ts, "UTC")(GH 56680)。已棄用
Timestamp.utcnow(),請使用Timestamp.now("UTC")(GH 56680)。已棄用
pd.core.internals.api.maybe_infer_ndim(GH 40226)。已棄用允許使用未包含在指定
dtype.categories中的非 NA 值的Categorical的構造或轉換(GH 40996)。已棄用在
DataFrame.all()、DataFrame.min()、DataFrame.max()、DataFrame.sum()、DataFrame.prod()、DataFrame.mean()、DataFrame.median()、DataFrame.sem()、DataFrame.var()、DataFrame.std()、DataFrame.skew()、DataFrame.kurt()、Series.all()、Series.min()、Series.max()、Series.sum()、Series.prod()、Series.mean()、Series.median()、Series.sem()、Series.var()、Series.std()、Series.skew()和Series.kurt()中允許非關鍵字引數。(GH 57087)已棄用在
DataFrame.groupby()和Series.groupby()中允許非關鍵字引數,除了by和level。(GH 62102)已棄用在
Series.to_markdown()中允許非關鍵字引數,除了buf。(GH 57280)已棄用在
Series.to_string()中允許非關鍵字引數,除了buf。(GH 57280)已棄用
DataFrameGroupBy.groups()和SeriesGroupBy.groups()在按包含單個元素的列表分組時返回標量字典鍵的行為。在未來版本中,字典鍵將返回元組。(GH 58858)已棄用
Series.dt.to_pytimedelta()的行為,在未來版本中,它將返回包含 Pythondatetime.timedelta物件的Series,而不是 timedelta 的ndarray;這與Series.dt()其他屬性的行為一致。(GH 57463)已棄用在寫入 stata 時,將包含
datetime.datetime物件的 object-dtype 列轉換為 datetime64(GH 56536)。已棄用
Day、BusinessDay和CustomBusinessDay中表示頻率的小寫字串d、b和c,改用D、B和C(GH 58998)。已棄用
Week中表示頻率的小寫字串w、w-mon、w-tue等,改用W、W-MON、W-TUE等(GH 58998)。已棄用
DataFrame.reindex_like()/Series.reindex_like()中的method引數(GH 58667)。已棄用
Timedelta中表示單位的字串w、d、MIN、MS、US和NS,改用W、D、min、ms、us和ns(GH 59051)。已棄用
Series.map()的arg引數;請改用新增的func引數。(GH 61260)已棄用
DataFrame.set_index()中的verify_integrity關鍵字;請直接檢查結果的obj.index.is_unique(GH 62919)。已棄用
testing.assert_frame_equal()和testing.assert_series_equal()中的check_datetimelike_compat關鍵字(GH 55638)。已棄用
DataFrame.to_json()和Series.to_json()中的epoch日期格式;請使用iso(GH 57063)。已棄用在
Series.unstack()和DataFrame.unstack()中允許無法被原始 dtype 持有的fill_value(整數和布林 dtype 的 NA 值除外)(GH 12189,GH 53868)。已棄用在
Series.shift()和DataFrame.shift()中允許無法被原始 dtype 持有的fill_value(整數和布林 dtype 的 NA 值除外)(GH 53802)。已棄用在
DataFrame.at_time()和Series.at_time()中允許表示完整日期的字串(GH 50839)。已棄用
DataFrame.select_dtypes()的向後相容行為,當指定np.object_時,該行為會匹配strdtype(GH 61916)。已棄用選項
future.no_silent_downcasting,因為它不再被使用。在未來版本中訪問此選項將引發錯誤(GH 59502)。已棄用將非 Index 型別傳遞給
Index.join();請先顯式轉換為 Index(GH 62897)。已棄用在
Series.combine_first()中,將非 datetime 型別的other自動轉換為 datetime 的行為(GH 62931)。已棄用使用
datetime.date物件對具有DatetimeIndex的Series或DataFrame進行切片;請先顯式轉換為Timestamp(GH 35830)。已棄用對 DataFrame Interchange Protocol 的支援(GH 56732)。
已棄用
Resampler.interpolate()中的inplace關鍵字,因為傳遞True會引發AttributeError(GH 58690)。
移除先前版本的棄用/更改#
強制棄用別名 M、Q、Y 等,改用 ME、QE、YE 等表示偏移量。#
重新命名了以下偏移量別名(GH 57986)。
偏移量 |
已移除的別名 |
新的別名 |
|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
其他移除項#
DataFrameGroupBy.idxmin()、DataFrameGroupBy.idxmax()、SeriesGroupBy.idxmin()和SeriesGroupBy.idxmax()現在將在組包含所有 NA 值時,或在使用skipna=False並遇到任何 NA 值時,引發ValueError(GH 10694,GH 57745)。concat()在所有條目均為 NA 的情況下,不再忽略這些條目的 dtype 來確定結果 dtype(GH 40893)。read_excel(),read_json(),read_html(), andread_xml()不再接受原始字串或位元組表示的資料。該型別的資料必須被包裝在StringIO或BytesIO中(GH 53767)to_datetime()指定了unit時,不再將字串解析為浮點數,而是像沒有unit一樣進行解析(GH 50735)SeriesGroupBy.agg()不再將組的名稱固定到傳遞給提供的func的輸入上(GH 51703)DataFrame.groupby()在使用as_index=False和聚合方法時,將不再從結果中排除不來自輸入的組合(GH 49519)ExtensionArray._reduce()現在要求在簽名中包含keepdims: bool = False引數(GH 52788)Series.dt.to_pydatetime()現在返回一個包含datetime.datetime物件的Series(GH 52459)除了
name之外,Index.rename()中的所有引數現在都只能透過關鍵字傳遞(GH 56493)IO 寫入器中除了第一個
path類引數之外的所有引數現在都只能透過關鍵字傳遞(GH 54229)更改了
Series.__getitem__()和Series.__setitem__()的行為,使其始終將整數鍵視為標籤,而非位置,這與DataFrame的行為一致(GH 50617)更改了具有浮點數索引的物件上,使用整數切片時的
Series.__getitem__()、Series.__setitem__()、DataFrame.__getitem__()、DataFrame.__setitem__()的行為。這現在被視為*位置*索引(GH 49612)不允許
Series.iloc()的可呼叫引數返回tuple(GH 53769)不允許在 pandas 物件和無 dtype 的序列(例如
list、tuple)之間進行邏輯運算(||、&、^);請先將物件包裝在Series、Index或np.array中(GH 52264)不允許在具有不匹配索引和非
object或bool的 dtype 的 Series 之間進行邏輯運算(&、^、||)時自動向上轉換為 object 型別(GH 52538)不允許在沒有
value且to_replace不是 dict 型別的情況下呼叫Series.replace()或DataFrame.replace()(GH 33302)不允許使用標量資料構建
arrays.SparseArray(GH 53039)不允許將非標準(
np.ndarray、Index、ExtensionArray或Series)型別傳遞給isin()、unique()、factorize()(GH 52986)不允許將 pandas 型別傳遞給
Index.view()(GH 55709)不允許在
array()中為 datetime64 和 timedelta64 dtypes 使用“s”、“ms”、“us”、“ns”以外的單位(GH 53817)從
pandas.core.internals和pandas.core.internals.api中移除了Block、DatetimeTZBlock、ExtensionBlock、create_block_manager_from_blocks(GH 55139)從
Categorical建構函式中移除了fastpath關鍵字引數(GH 20110)從
PeriodArray建構函式中移除了freq關鍵字引數,請使用“dtype”代替(GH 52462)從
Series.resample()和DataFrame.resample()中移除了kind關鍵字引數(GH 58125)移除了
arrays.NumpyExtensionArray的別名arrays.PandasArray(GH 53694)從
Series.replace()和DataFrame.replace()中移除了已棄用的method和limit關鍵字引數(GH 53492)移除了擴充套件測試類
BaseNoReduceTests、BaseNumericReduceTests、BaseBooleanReduceTests(GH 54663)從
DatetimeIndex建構函式中移除了closed和normalize關鍵字引數(GH 52628)移除了
read_csv()和read_table()中已棄用的delim_whitespace關鍵字引數,請使用sep=r"\s+"代替(GH 55569)要求
SparseDtype.fill_value()是SparseDtype.subtype()的有效值(GH 53043)停止在
Series.isin()和Index.isin()中自動將非日期時間類值(主要是字串)強制轉換為datetime64、timedelta64和PeriodDtypedtypes(GH 53111)在
Index、Series和DataFrame建構函式中,當輸入是 pandas 物件(Series、Index、ExtensionArray)時,停止進行 dtype 推理。要保留當前行為,請先在輸入上呼叫.infer_objects(GH 56012)在
Index.insert()中,當使用 object-dtype 索引時,停止進行 dtype 推理;這通常會影響將新條目設定到空的Series或DataFrame時產生的索引/列(GH 51363)從
TimedeltaIndex建構函式中移除了closed和unit關鍵字引數(GH 52628, GH 55499)Index.sort_values()中的所有引數現在都只能透過關鍵字傳遞(GH 56493)Series.to_dict()中的所有引數現在都只能透過關鍵字傳遞(GH 56493)將
Categorical.map()中na_action的預設值更改為None(GH 51645)將
DataFrame.groupby()和Series.groupby()中observed的預設值更改為True(GH 51811)強制在
testing.assert_series_equal()和testing.assert_frame_equal()中,對於 object dtype 和不匹配的 null-like 值(現在被視為不相等)進行棄用強制執行(GH 18463)強制執行
datetime64、DatetimeTZDtype和PeriodDtypedtypes 上all和any約簡的棄用強制執行(GH 58029)強制執行
str.contains()、str.startswith()和str.endswith()中,na引數不允許非bool和 NA 值(GH 59615)強制執行
date_range()、period_range()、timedelta_range()、interval_range()中periods引數不允許float型別(GH 56036)強制執行
to_datetime()解析混合時區字串的棄用,除非使用者傳遞utc=True(GH 57275)強制執行
Series.value_counts()和Index.value_counts()在 object dtype 時,對結果的.index進行 dtype 推理的棄用強制執行(GH 56161)強制執行
DataFrameGroupBy.get_group()和SeriesGroupBy.get_group()允許name引數為長度為 1 的列表分組時的非元組值的棄用強制執行(GH 54155)強制執行
Series.interpolate()和DataFrame.interpolate()在 object-dtype 上的棄用強制執行(GH 57820)強制執行
offsets.Tick.delta()的棄用,請使用pd.Timedelta(obj)代替(GH 55498)強制執行 DataFrame 約簡
sum、prod、std、var和sem中axis=None等同於axis=0的行為的棄用。現在axis=None將在兩個軸上進行約簡;特別是在執行如numpy.sum(df)時(GH 21597)強制執行
core.internals成員DatetimeTZBlock的棄用(GH 58467)在
read_csv()、read_table()、read_fwf()和read_excel()中,date_parser引數的棄用,建議使用date_format(GH 50601)在
read_csv()中,keep_date_col關鍵字引數的棄用(GH 55569)在
Rolling.quantile()和Expanding.quantile()中,quantile關鍵字引數的棄用,已重新命名為q。(GH 52550)在
read_csv()中,infer_datetime_format引數的棄用,因為其嚴格版本已成為預設值(GH 48621)在
read_csv()的parse_dates中,組合解析的日期列的棄用(GH 55569)強制執行
api.extensions.take()引數中非標準(np.ndarray、ExtensionArray、Index或Series)型別的棄用強制執行(GH 52981)強制執行解析系統時區字串到
tzlocal的棄用,因為它依賴於系統時區,請改用傳遞tz關鍵字引數(GH 50791)強制執行向
SeriesGroupBy.agg()傳遞字典的棄用強制執行(GH 52268)強制執行
YearBegin中表示頻率的字串AS,以及表示具有各種財年起點的年度頻率的字串AS-DEC、AS-JAN等的棄用(GH 57793)強制棄用
YearEnd中表示頻率的字串A,以及表示具有不同財年末年度頻率的字串A-DEC、A-JAN等 (GH 57699)強制棄用
BYearBegin中表示頻率的字串BAS,以及表示具有不同財年起始年度頻率的字串BAS-DEC、BAS-JAN等 (GH 57793)強制棄用
BYearEnd中表示頻率的字串BA,以及表示具有不同財年末年度頻率的字串BA-DEC、BA-JAN等 (GH 57793)強制棄用
Hour、BusinessHour和CustomBusinessHour中表示頻率的字串H、BH和CBH(GH 59143)強制棄用
Timedelta中表示單位的字串H、BH和CBH(GH 59143)強制棄用
Minute、Milli、Micro、Nano中表示頻率的字串T、L、U和N(GH 57627)強制棄用
Timedelta中表示單位的字串T、L、U和N(GH 57627)強制棄用
在concat()len(keys) != len(objs)時截斷到較短長度的行為。現在這會引發ValueError(GH 43485)強制棄用
和DataFrame.replace()中可能引入新類別的Series.replace()CategoricalDtype的行為。(GH 58270)強制棄用
在存在 NA 值時(GH 58232)的行為。Series.argsort()強制棄用
和Series.interpolate()中的值“pad”、“ffill”、“bfill”和“backfill”(GH 57869)DataFrame.interpolate()強制棄用並移除
Categorical.to_list(),請改用obj.tolist()(GH 51254)在
中,DataFrame.stack()future_stack的預設值現在為True;指定False將引發FutureWarning(GH 55448)按
level(長度為 1 的列表)對DataFrameGroupBy或SeriesGroupBy進行迭代時,將返回長度為 1 的組的元組 (GH 50064)方法
apply、agg和transform將不再用等效的 pandas 實現替換 NumPy 函式(例如np.sum)和內建函式(例如min);如果您希望使用 pandas 實現,請使用字串別名(例如"sum"和"min")(GH 53974)在
、DataFrame.shift()和Series.shift()中同時傳遞DataFrameGroupBy.shift()freq和fill_value現在會引發ValueError(GH 54818)移除了支援布林 dtype 的
和DataFrameGroupBy.quantile()(GH 53975)SeriesGroupBy.quantile()移除了
DateOffset.is_anchored()和offsets.Tick.is_anchored()(GH 56594)移除了
DataFrame.applymap、Styler.applymap和Styler.applymap_index(GH 52364)移除了
DataFrame.bool和Series.bool(GH 51756)移除了
DataFrame.first和DataFrame.last(GH 53710)移除了
DataFrame.swapaxes和Series.swapaxes(GH 51946)移除了
DataFrameGroupBy.grouper和SeriesGroupBy.grouper(GH 56521)移除了
DataFrameGroupby.fillna和SeriesGroupBy.fillna`(GH 55719)移除了
Index.format,請改用str型別的或帶有Index.astype()formatter函式的(GH 55439)Index.map()移除了
Resample.fillna(GH 55719)移除了
Series.__int__和Series.__float__。請改用int(Series.iloc[0])或float(Series.iloc[0])。(GH 51131)移除了
Series.ravel(GH 56053)移除了
Series.view(GH 56054)移除了
StataReader.close(GH 49228)從
、DataFrame、Series中移除了arrays.ArrowExtensionArray_data(GH 52003)從
、DataFrame.groupby()、Series.groupby()、DataFrame.rolling()、Series.rolling()和DataFrame.resample()中移除了Series.resample()axis引數 (GH 51203)移除了所有 groupby 操作中的
axis引數 (GH 50405)移除了
中的Series.apply()convert_dtype(GH 52257)移除了
中的DataFrame.align()method、limit、fill_axis和broadcast_axis關鍵字 (GH 51968)移除了
pandas.api.types.is_interval和pandas.api.types.is_period,請改用isinstance(obj, pd.Interval)和isinstance(obj, pd.Period)(GH 55264)移除了
pandas.io.sql.execute(GH 50185)移除了
pandas.value_counts,請改用(GH 53493)Series.value_counts()移除了
read_gbq和DataFrame.to_gbq。請改用pandas_gbq.read_gbq和pandas_gbq.to_gbqhttps://pandas-gbq.readthedocs.io/en/latest/api.html (GH 55525)移除了
中的read_parquet()use_nullable_dtypes(GH 51853)移除了
建構函式中的PeriodIndexyear、month、quarter、day、hour、minute和second關鍵字,請改用(GH 55960)PeriodIndex.from_fields()從
、DataFrame.pct_change()、Series.pct_change()和DataFrameGroupBy.pct_change()中移除了SeriesGroupBy.pct_change()limit引數;method引數必須設定為None,並且將在 pandas 的未來版本中移除(GH 53520)移除了
和DataFrameGroupBy.get_group()中已棄用的SeriesGroupBy.get_group()obj引數(GH 53545)移除了
使用Series.agg()的已棄用行為(GH 53325)Series.apply()移除了
和Series.fillna()中的已棄用關鍵字DataFrame.fillna()method(GH 57760)移除了選項
mode.use_inf_as_na,請先將 inf 條目轉換為NaN(GH 51684)移除了對
中DataFrame.from_records()的支援(GH 51697)DataFrame移除了對
、to_datetime()和to_timedelta()中to_numeric()errors="ignore"的支援(GH 55734)移除了對
中DataFrame.take()slice的支援(GH 51539)移除了
ArrayManager(GH 55043)移除了
建構函式中的Seriesfastpath引數 (GH 55466)移除了
的Indexis_boolean、is_integer、is_floating、holds_integer、is_numeric、is_categorical、is_object和is_interval屬性 (GH 50042)移除了
中的PeriodIndexordinal關鍵字,請改用(GH 55960)PeriodIndex.from_ordinals()移除了
Resampler方法中的未使用引數*args和**kwargs(GH 50977)解析字串到日期時間時,無法識別的時區現在會引發
ValueError(GH 51477)移除了
的屬性Grouperax、groups、indexer和obj(GH 51206, GH 51182)移除了
和read_csv()中的已棄用關鍵字read_table()verbose(GH 56556)移除了
中的ExtensionArray.fillna()method關鍵字,請改用ExtensionArray._pad_or_backfill(GH 53621)移除了
DataFrameGroupBy的dtypes屬性 (GH 51997)強制棄用
argmin、argmax、idxmin和idxmax在skipna=False且遇到 NA 值或所有值都是 NA 值時返回結果的行為;這些操作現在在這種情況下會引發錯誤(GH 33941, GH 51276)強制棄用
的儲存選項“pyarrow_numpy”(GH 60152)StringDtype移除了在
和DataFrameGroupBy.apply()中指定Resampler.apply()include_groups=True(GH 7155)
效能改進#
消除了訪問器屬性(例如
)中到原始 pandas 物件的迴圈引用。但是,訪問器例項化不再被快取(GH 47667, GH 41357)Series.str當構造的
values是range時,返回Categorical.categoriesRangeIndex列而不是。(GH 57787)Index當
data是dict時,在可能的情況下返回DataFrameRangeIndex列(GH 57943)當
data是dict時,在可能的情況下返回SeriesRangeIndex索引(GH 58118)當
objs包含和Series且DataFrameaxis=0時,在可能的情況下返回concat()RangeIndex列(GH 58119)當
keys是range或RangeIndex時,在concat()MultiIndex結果中返回RangeIndex級別(GH 57542)當追加的值可以繼續
時,RangeIndexRangeIndex.append()返回RangeIndex而不是(GH 57467)Index當索引中有重複值時,
的效能有所提高(GH 55767)Series.nlargest()當可能時,
返回Series.str.extract()RangeIndex列而不是列(GH 57542)IndexSeries.str.partition()結合ArrowDtype在可能的情況下返回RangeIndex列而不是Index列(GH 57768)在
MultiIndex中,設定MultiIndex.names不會使所有快取的操作失效,效能得到提升(GH 59578)在
DataFrameGroupBy.ffill()、DataFrameGroupBy.bfill()、SeriesGroupBy.ffill()和SeriesGroupBy.bfill()中,效能得到提升(GH 56902)在
DataFrame.join()中,對於已排序但非唯一的索引,效能得到提升(GH 56941)在
DataFrame.join()中,當左右索引非唯一且how為"left"、"right"或"inner"時,效能得到提升(GH 56817)在
DataFrame.join()中,當how="left"或how="right"且sort=True時,效能得到提升(GH 56919)在
DataFrame.to_csv()中,當index=False時,效能得到提升(GH 59312)在
Index.join()中,透過在結果與輸入之一匹配的情況下傳播快取屬性,效能得到提升(GH 57023)在
Index.take()中,當indices是從零到索引長度的完整範圍索引器時,效能得到提升(GH 56806)在
Index.to_frame()中,在可能的情況下返回RangeIndex列的Index,效能得到提升(GH 58018)在
MultiIndex._engine()中,使用更小的 dtype(如果可能),效能得到提升(GH 58411)在
MultiIndex.equals()中,對於等長索引,效能得到提升(GH 56990)在
MultiIndex.memory_usage()中,忽略未快取的索引引擎,效能得到提升(GH 58385)在
RangeIndex.__getitem__()中,當使用布林掩碼或整數時,在可能的情況下返回RangeIndex而不是Index,效能得到提升(GH 57588)在
RangeIndex.append()中,當追加相同的索引時,效能得到提升(GH 57252)在
RangeIndex.argmin()和RangeIndex.argmax()中,效能得到提升(GH 57823)在
RangeIndex.insert()中,當RangeIndex為空時,返回RangeIndex而不是Index,效能得到提升(GH 57833)在
RangeIndex.round()中,在可能的情況下返回RangeIndex而不是Index,效能得到提升(GH 57824)在
RangeIndex.searchsorted()中,效能得到提升(GH 58376)在
RangeIndex.to_numpy()中,指定na_value時,效能得到提升(GH 58376)在
RangeIndex.value_counts()中,效能得到提升(GH 58376)在
RangeIndex.join()中,在可能的情況下返回RangeIndex而不是Index,效能得到提升(GH 57651, GH 57752)在
RangeIndex.reindex()中,在可能的情況下返回RangeIndex而不是Index,效能得到提升(GH 57647, GH 57752)在
RangeIndex.take()中,在可能的情況下返回RangeIndex而不是Index,效能得到提升(GH 57445, GH 57752)在
CategoricalDtype.update_dtype()中,當dtype是具有非None類別且有序的CategoricalDtype時,效能得到提升(GH 59647)在
DataFrame.__getitem__()中,當key是一個具有許多列的DataFrame時,效能得到提升(GH 61010)在
DataFrame.astype()中,當轉換為擴充套件浮點數 dtype(例如 “Float64”)時,效能得到提升(GH 60066)在
DataFrame.merge()中,透過為所有基於 Arrow 的 dtype 使用 Arrow 原生路徑,效能得到提升(GH 63435)在
DataFrame.stack()中,當使用future_stack=True且 DataFrame 沒有MultiIndex時,效能得到提升(GH 58391)在
DataFrame.to_hdf()中,避免不必要地重新開啟 HDF5 檔案,以加快向具有大量組的檔案新增資料的速度(GH 58248)在
DataFrame.where()中,當cond是一個具有許多列的DataFrame時,效能得到提升(GH 61010)在
DataFrameGroupBy.__len__和SeriesGroupBy.__len__中,效能得到提升(GH 57595)在字串 dtype 的索引操作中,效能得到提升(GH 56997)
在
RangeIndex上的一元方法中,在可能的情況下返回RangeIndex而不是Index,效能得到提升(GH 57825)
Bug 修復#
分類#
在使用具有
ArrowDtype的Index構建Categorical時存在錯誤(GH 60563)在
Categorical中,從具有dtype='object'的 pandasSeries或Index構建時,未能將類別的 dtype 保持為object;現在,對於這些情況,categories.dtype被保持為object,而具有dtype='object'的 numpy 陣列和 Python 序列繼續推斷最具體的 dtype(例如,如果所有元素都是字串,則推斷為str)(GH 61778)在
pandas.Categorical中,在使用“string”dtype 時顯示不帶引號的字串類別存在錯誤(GH 63045)在
Series.apply()中,對於CategoricalDtype,nan被忽略存在錯誤(GH 59938)在
bdate_range()中,使用頻率freq="cbh"會引發ValueError存在錯誤(GH 62849)在
testing.assert_index_equal()中,當check_categorical=True且exact=False時,對於不可比較的CategoricalIndex,會引發TypeError而不是AssertionError(GH 61935)在
Categorical.astype()中,當copy=False時,仍然會觸發程式碼的複製存在錯誤(GH 62000)在
DataFrame.pivot()和DataFrame.set_index()中,對於具有 pyarrow 字典 dtype 的列,會引發ArrowNotImplementedError存在錯誤(GH 53051)在
Series.convert_dtypes()中,當dtype_backend="pyarrow"時,空的CategoricalDtypeSeries引發錯誤或被轉換為null[pyarrow]存在錯誤(GH 59934)
日期時間型別#
在
is_year_start中,透過date_range()使用頻率 'MS' 構建的DatetimeIndex的年份或季度開始屬性不正確存在錯誤(GH 57377)在
DataFrame中,當dtype是timedelta64且data是包含None的列表時,引發ValueError存在錯誤(GH 60064)在
Timestamp建構函式中,當顯式指定tz=None與時區感知的tzinfo或資料結合使用時,未能引發錯誤存在錯誤(GH 48688)在
Timestamp建構函式中,當給定非標準單位的np.datetime64物件時,未能引發錯誤存在錯誤(GH 25611)在
date_range()中,有時最後一個有效時間戳未能生成存在錯誤(GH 56134)在
date_range()中,使用負頻率值時,未能包含開始和結束值之間的所有點存在錯誤(GH 56147)在
infer_freq()中,對具有ArrowDtype時間戳 dtype 的Series,錯誤地引發TypeError(GH 58403)在
to_datetime()中,將lxml.etree._ElementUnicodeResult與format一起傳遞時引發TypeError存在錯誤。現在已處理str的子類(GH 60933)在
tseries.api.guess_datetime_format()中,當 “%Y” == “%H%M” 時,會失敗,無法推斷時間格式(GH 57452)在
tseries.frequencies.to_offset()中,無法解析以 “LWOM” 開頭的頻率字串存在錯誤(GH 59218)在
DateOffset.rollback()(及子類方法)中,當normalize=True時,回滾長度會多一個偏移量存在錯誤(GH 32616)在
DataFrame.agg()中,處理缺失值時導致IndexError存在錯誤(GH 58810)在
DataFrame.fillna()中,當使用超出範圍的時間戳填充datetime64[ns]列時,會引發AssertionError而不是OutOfBoundsDatetime。現在正確引發OutOfBoundsDatetime(GH 61208)在
DataFrame.min()和DataFrame.max()中,將datetime64和timedelta64列轉換為float64並丟失精度存在錯誤(GH 60850)在
DatetimeIndex.asof()中,使用字串鍵會導致不正確的結果存在錯誤(GH 50946)在
DatetimeIndex.is_year_start()和DatetimeIndex.is_quarter_start()中,對於大於 “1C” 的自定義營業日頻率,不會引發錯誤存在錯誤(GH 58664)在
DatetimeIndex.is_year_start()和DatetimeIndex.is_quarter_start()中,對於雙位數頻率返回False存在錯誤(GH 58523)在
DatetimeIndex.union()和DatetimeIndex.intersection()中,當unit非納秒時存在錯誤(GH 59036)在
DatetimeIndex.where()和TimedeltaIndex.where()中,在某些情況下未能設定freq=None存在錯誤(GH 24555)在
Index.union()中使用pyarrow時間戳 dtype 時出現錯誤,錯誤地返回objectdtype(GH 58421)在
Series.dt.microsecond()中使用 pyarrow 支援的Series時,產生不正確的結果(GH 59154)在
Timestamp.normalize()和DatetimeArray.normalize()中出現錯誤,當非常小(遙遠的過去)的值導致整數溢位時,不會引發錯誤,而是返回不正確的結果(GH 60583)在
Timestamp.replace()中出現錯誤,當替換引入非零nanosecond或microsecond時,未能更新unit屬性(GH 57749)在
to_datetime()中出現錯誤,當傳遞不常見的日期字串時,不尊重 `dayfirst` 引數(GH 58859)在
to_datetime()中對包含缺失值的浮點數陣列進行操作時,會引發FloatingPointError(GH 58419)在
to_datetime()中處理具有年、月、日等列的 float32 資料時,會導致精度問題和不正確的結果(GH 60506)在
to_datetime()中出現錯誤,在任何失敗場景下都會報告不正確的索引(GH 58298)在
to_datetime()中使用format="ISO8601"和utc=True時出現錯誤,本地時間戳會錯誤地繼承系列中前一個時間戳的時區偏移(GH 61389)在
to_datetime()中,當 `arg` 是具有 `ps` 單元的 `np.datetime64` 物件時,會錯誤地進行轉換(GH 60341)在具有 `np.datetime64` dtype 和 `timestamp[pyarrow]` dtypes 的物件之間進行比較時出現錯誤,錯誤地引發
TypeError(GH 60937)在具有 pyarrow date dtype 和 `timestamp[pyarrow]` 或 `np.datetime64` dtype 的物件之間進行比較時出現錯誤,未能將它們視為不可比較(GH 62157)
在使用具有 `timestamp` 型別的
ArrowDtype構建陣列時出現錯誤,錯誤地允許 `Decimal("NaN")`(GH 61773)在從時區感知的
ArrowDtype構建時區感知的陣列時出現錯誤,當 `tz=None` 時,錯誤地將這些視為 UTC 時間,而不是像DatetimeTZDtype那樣視為本地時間(GH 61775)在
value_counts()中保留頻率時出現錯誤,特別是對於DatetimeIndex()和TimedeltaIndex()(GH 33830)在將具有不匹配解析度的標量值設定到具有非納秒
datetime64、timedelta64或DatetimeTZDtype的陣列中時出現錯誤,錯誤地截斷這些標量(GH 56410)
時間差#
在
Timedelta.to_pytimedelta()中提高了精度,以便對基於納秒的大型 Timedelta 一致地四捨五入微秒(GH 57841)在
DataFrame.cumsum()中出現錯誤,當 dtype 為timedelta64[ns]時會引發IndexError(GH 57956)在將非納秒單位的
Timedelta物件與 Pythondatetime.datetime物件相加或相減時出現錯誤,導致結果不正確;現在當 Timedeltas 在datetime.timedelta實現範圍之內時,此操作可以正常工作(GH 53643)在具有 `timedelta64` dtype 的乘法運算中出現錯誤,當乘以布林物件或 dtype 時未能引發
TypeError(GH 58054)在具有 `timedelta64` dtype 的乘法運算中出現錯誤,當乘以 numpy 可空 dtype 或 pyarrow 整數 dtype 時錯誤地引發(GH 58054)
在
Series建構函式中出現錯誤,當從整數構建 timedelta 序列時,未能遵循 `timedelta64[unit]` dtype 的單位,例如 `pd.Series([0, 1, 2], dtype="timedelta64[s]")` 仍然將數字解釋為納秒而不是秒。現在,它將根據指定 dtype 的單位解釋傳入的整數(GH 48312, GH 52457)
時區#
在
DatetimeIndex.union()、DatetimeIndex.intersection()和DatetimeIndex.symmetric_difference()中出現錯誤,當合並兩個具有相同時區但不同單位的 DatetimeIndex 物件時,時區被更改為 UTC(GH 60080)在
Series.dt.tz_localize()中使用時區感知的ArrowDtype時,當 `tz=None` 時,錯誤地轉換為 UTC(GH 61780)修復了
date_range()中的錯誤,當時區感知的端點帶有日曆偏移量(例如 `"MS"`)時,在 DST 回溯時會失敗。現在這些端點會尊重 `ambiguous`/`nonexistent` 引數(GH 52908)
數值#
在
api.types.infer_dtype()中出現錯誤,對於 complex 和 `pd.NA` 的混合,返回 "mixed"(GH 61976)在
api.types.infer_dtype()中出現錯誤,對於 float 和 `pd.NA` 的混合,返回 "mixed-integer-float"(GH 61621)在
DataFrame.combine_first()中出現錯誤,其中絕對值大於 `2**53` 的 Int64 和 UInt64 整數在操作後會丟失精度(GH 60128)在
DataFrame.corr()中出現錯誤,數值精度問題導致相關性大於 `1.0`(GH 61120)在
DataFrame.cov()中出現錯誤,會引發TypeError,而不是返回可能不正確的結果或其他錯誤(GH 53115)在
DataFrame.quantile()中出現錯誤,當 `numeric_only=True` 且 `q` 是類列表時,列型別未被保留,併產生空結果(GH 59035)在
Series.dot()中出現錯誤,對於ArrowDtype和可空 dtype 的資料,返回objectdtype(GH 61375)在
Series.std()和Series.var()中使用複數值資料時出現錯誤(GH 61645)在 numpy 可空 dtype 和
ArrowDtype物件之間的算術運算中出現錯誤,錯誤地引發(GH 58602)
轉換#
to_numeric()對大整數進行操作時,在未進行強制轉換的情況下,會轉換為具有 python 整數的object資料型別(GH 51295)在
DataFrame.astype()中出現錯誤,未正確轉換 Arrow 基礎字典 dtype 的 `values`(GH 58479)在
DataFrame.update()中,bool dtype 被轉換為 object(GH 55509)在
Series.astype()中出現錯誤,當轉換為字串 dtype 時,可能會就地修改只讀陣列(GH 57212)在
Series.convert_dtypes()和DataFrame.convert_dtypes()中,當對包含複數 dtype 的資料呼叫時會引發TypeError(GH 60129)在
Series.convert_dtypes()和DataFrame.convert_dtypes()中,對於具有ArrowDtype的物件,會移除時區資訊(GH 60237)在
Series.reindex()中出現錯誤,當 `reindex` 引入缺失值時,未能保持 `float32` 型別(GH 45857)在
to_datetime()和to_timedelta()中,當輸入為 `None` 時,返回 `None` 而不是 `NaT`,這與其他轉換方法不一致(GH 23055)
字串#
在
Series.str.match()中出現錯誤,當給定一個編譯的 `re.Pattern` 物件以及衝突的 `case` 或 `flags` 引數時,未能引發錯誤(GH 62240)在
Series.str.replace()中,對於轉換為 PyArrow 後端 dtype 的系列,當使用有效的組引用(`\1`、`\2` 等)時會引發錯誤(GH 62653)在
Series.str.zfill()中,對於ArrowDtype會引發AttributeError(GH 61485)在
Series.value_counts()中出現錯誤,對於具有 `string` dtype 的系列,不會尊重 `sort=False` 引數(GH 55224)在 Series.str methods 中出現錯誤,當在 PyArrow 支援的資料上使用帶有前瞻/後顧、反向引用或 `\Z` 的正則表示式時會失敗(GH 60833, GH 63683)
在與
StringDtype的乘法運算中出現錯誤,錯誤地允許與布林值相乘;現在會顯式轉換為整數(GH 62595)
Interval#
Index.is_monotonic_decreasing()、Index.is_monotonic_increasing()和Index.is_unique()對於從另一個Index的切片建立的Index,可能錯誤地返回False(GH 57911)在
Index、Series、DataFrame建構函式中,當給定一系列Interval子類物件時,會出現錯誤,會將它們強制轉換為Interval(GH 46945)在
interval_range()中出現錯誤,start 和 end 的數值型別總是被強制轉換為 64 位(GH 57268)在
pandas.interval_range()中出現錯誤,當 `start` 和 `freq` 分別使用 `np.float32` 和 `int` 時,會錯誤地推斷出 `int64` dtype(GH 58964)在
IntervalIndex.get_indexer()和IntervalIndex.drop()中,當索引的某一邊是非唯一時出現錯誤(GH 52245)從具有不匹配的有符號/無符號整數 dtype(例如 `int64` 和 `uint64`)的陣列構建
IntervalArray和IntervalIndex現在會引發TypeError,而不是靜默進行。 (GH 55715)
索引#
在
DataFrame.__getitem__()中,當切片一個有很多行的DataFrame時,會引發OverflowError(GH 59531)在
DataFrame.__setitem__()中,對一個空的DataFrame使用元組時,會損壞該幀(GH 54385)在
DataFrame.from_records()中,當在 `index` 中傳遞空列表時,會引發ValueError(GH 58594)在
DataFrame.loc()和DataFrame.iloc()中,當從具有混合資料型別的DataFrame中選擇時,返回了不正確的 dtype(GH 60600)在
DataFrame.loc()中,當向 Series 設定兩個索引時,loc-set 的行為不一致(GH 59933)在
Index.equals()中,當比較具有字串 dtype 的Series和Index時出現錯誤(GH 61099)Index.get_indexer() 及類似方法在 NaN 位於第 128 位或之後時出現錯誤(GH 58924)
MultiIndex.insert() 在插入到類 datetime 的級別的新值被強制轉換為 NaT 並導致索引失敗時出現錯誤(GH 60388)
Series.__setitem__() 在分配帶有布林索引器的布林 Series 時會引發 LossySetitemError(GH 57338)
使用解析度高於索引的 DatetimeIndex 和 Timestamp 端點對 obj.loc[start:stop] 進行索引時出現錯誤(GH 63262)
列印 Index.names 和 MultiIndex.levels 時不會轉義單引號(GH 60190)
在合併塊的情況下,使用 PeriodDtype 列對 DataFrame 進行重新索引時出現錯誤(GH 60980、GH 60273)
DataFrame.__getitem__() 在 Python 3.12 中使用 slice 呼叫時返回已修改的列(GH 57500)
DataFrame.loc.__getitem__() 和 DataFrame.iloc.__getitem__() 在具有整數類別的 CategoricalDtype 列上使用時,在嘗試索引包含 NaN 條目的行時會引發錯誤(GH 58954)
Index.__getitem__() 在使用 0 維 np.ndarray 鍵時錯誤地引發異常(GH 55601)
Index.get_indexer() 在未正確轉換新字串資料型別缺失值時出現錯誤(GH 55833)
Index.intersection()、Index.union()、MultiIndex.intersection() 和 MultiIndex.union() 在對相同索引進行操作時返回原始 Index 的引用而不是新例項,這可能導致修改結果時元資料損壞(GH 63169)
使用 DataFrame.loc.__setitem__() 或 Series.loc.__setitem__() 新增新行時出現錯誤,在某些情況下未能保留物件索引上的 dtype(GH 41626)
在具有 timestamp[pyarrow] dtype 的 DatetimeIndex 上或具有 duration[pyarrow] dtype 的 TimedeltaIndex 上進行索引時出現錯誤(GH 62277)
Missing#
DataFrame.fillna() 和 Series.fillna() 在 ExtensionArray dtype 上忽略 limit 引數時出現錯誤(GH 58001)
MultiIndex.fillna() 的錯誤訊息引用了 isna 而不是 fillna(GH 60974)
NA.__and__()、NA.__or__() 和 NA.__xor__() 在與 np.bool_ 物件操作時出現錯誤(GH 58427)
NA 和 Int64 dtype 物件之間的 divmod 操作出現錯誤(GH 62196)
修復了 Series.replace() 和 DataFrame.replace() 在嘗試替換 Float64Dtype 物件中的 NA 值(使用 np.nan)時的錯誤;現在使用 pd.set_option("mode.distinguish_nan_and_na", True) 可以正常工作,否則則無關緊要(GH 55127)
修復了 Series.replace() 和 DataFrame.replace() 在嘗試替換 Int64Dtype 物件中的 np.nan 值(使用 NA)時的錯誤;現在使用 pd.set_option("mode.distinguish_nan_and_na", True) 為無操作,否則則無關緊要(GH 51237)
MultiIndex#
DataFrame.loc() 在 axis=0 和 MultiIndex 上設定值時,會新增額外的列(GH 58116)
DataFrame.melt() 在列是 MultiIndex 時,不接受 var_name 中的多個名稱(GH 58033)
MultiIndex.insert() 在 unified location of index -1 處未正確插入 NA 值(GH 59003)
MultiIndex.get_level_values() 訪問 DatetimeIndex 時未沿襲 frequency 屬性(GH 58327、GH 57949)
在具有未對齊 MultiIndex 列的 DataFrame 算術運算中出現錯誤(GH 60498)
在具有未對齊 MultiIndex 的 Series 的 DataFrame 算術運算中出現錯誤(GH 61009)
MultiIndex.union() 在索引具有不同名稱的重複項時引發錯誤(GH 62059)
MultiIndex.from_tuples() 在輸入包含 NaN 值的元組時導致輸出錯誤的錯誤(GH 60695、GH 60988)
DataFrame.__setitem__() 中的列對齊邏輯會使用空索引重新索引分配的值,從而錯誤地將所有值設定為 NaN(GH 61841)
DataFrame.reindex() 和 Series.reindex() 在將 Index 重新索引到 MultiIndex 時,會錯誤地將所有值設定為 NaN(GH 60923)
I/O#
DataFrame 和 Series 中 collections.abc.Mapping 元素的 repr 出現錯誤(GH 57915)
DataFrame.to_hdf() 和 read_hdf() 在處理具有非納秒解析度的 timedelta64 dtype 時,未能正確地往返(GH 63239)
修復了 on_bad_lines 可呼叫物件在返回過多欄位時的錯誤:現在會發出 ParserWarning 並截斷額外欄位,無論 index_col 如何(GH 61837)
pandas.json_normalize() 在設定 max_level 時,對 data 中非 dict 項的處理不一致。現在,如果 data 是包含非 dict 項的列表,則該函式將引發 TypeError(GH 62829)
pandas.json_normalize() 在 meta 包含非字串鍵(例如 int)且指定了 record_path 時引發 TypeError,這與 record_path 為 None 時的行為不一致(GH 63019)
DataFrame.to_json() 在 index 引數是 DataFrame.column 中的值且 Index.name 為 None 時出現錯誤。現在,這會引發 ValueError(GH 58925)
io.common.is_fsspec_url() 未能識別連結的 fsspec URL(GH 48978)
DataFrame._repr_html_() 忽略了 "display.float_format" 選項(GH 59876)
DataFrame.from_records() 在 data 是空迭代器且 nrows=0 時,忽略了 columns 和 index 引數(GH 61140)
DataFrame.from_records() 未能正確初始化子類(GH 57008)
DataFrame.from_records() 中,當 columns 引數是 numpy 結構化陣列時,未能重新排序和過濾掉列(GH 59717)
DataFrame.to_dict() 在列不唯一且 orient='tight' 時引發不必要的 UserWarning(GH 58281)
DataFrame.to_excel() 在寫入空的 DataFrame(兩軸均為 MultiIndex)時出現錯誤(GH 57696)
DataFrame.to_excel() 中,具有 period 級別的 MultiIndex 索引不是日期的錯誤(GH 60099)
DataFrame.to_stata() 在匯出包含長字串(Stata strL)和 pd.NA 值的列時出現錯誤(GH 23633)
DataFrame.to_stata() 在編碼長度和普通長度不匹配時出現錯誤(GH 61583)
DataFrame.to_stata() 在寫入 DataFrame 且 byteorder='big' 時出現錯誤(GH 58969)
DataFrame.to_stata() 在寫入超過 32000 個值標籤時出現錯誤(GH 60107)
DataFrame.to_string() 在處理巢狀 DataFrame 時引發 StopIteration 的錯誤(GH 16098)
HDFStore.get() 未能正確儲存 datetime64[s] dtype 的資料(GH 59004)
HDFStore.select() 在對分類字串列進行查詢時導致意外結果(GH 57608)
MultiIndex.factorize() 在處理長度為 0 的索引時錯誤地引發異常(GH 57517)
read_csv() 在 encoding_errors 不是字串時導致分段錯誤(GH 59059)
read_csv() 的 c 和 python 引擎在解析具有大指數的數字時導致溢位。現在,具有大正指數的數字將解析為 inf 或 -inf(取決於尾數的符號),而具有大負指數的數字將解析為 0.0(GH 62617、GH 38794、GH 62740)
DataFrame.to_csv() 中,當 escapechar 不是 None 時,quotechar 未被轉義(GH 61407)
read_csv() 在指定 index_col 且 na_values 是包含 None 鍵的字典時引發 TypeError(GH 57547)
read_csv() 在指定 nrows 和 iterator 但未指定 chunksize 時引發 TypeError(GH 59079)
read_csv() 中,連結的 fsspec TAR 檔案和 compression="infer" 導致 tarfile.ReadError(GH 60028)
read_csv() 未能適當地跳過指示的行,導致空資料錯誤(GH 62739)
read_csv() 中,當 na_values 是非字串值的列表時,na_values 的順序導致不一致(GH 59303)
read_csv() 的 c 和 python 引擎將大整數讀取為字串。現在將它們讀取為 python 整數(GH 51295)
read_csv() 的 engine="c" 在讀取具有前導整數的大浮點數時將其讀取為字串。現在將它們讀取為浮點數(GH 51295)
read_csv() 的 engine="pyarrow" 和 dtype="Int64" 導致精度損失(GH 56136)
read_excel() 在 dtype="boolean" 時,傳遞布林值陣列會引發 ValueError(GH 58159)
read_html() 中,標題行中的 rowspan 導致錯誤地轉換為 DataFrame(GH 60210)
read_json() 在 engine="pyarrow" 時忽略給定的 dtype 的錯誤 (GH 59516)
read_json() 在 typ 引數不嚴格等於 "frame" 或 "series" 時不進行驗證的錯誤 (GH 59124)
read_json() 在字串形式的極端值整數被錯誤地解析為不同整數的錯誤 (GH 20608)
read_stata() 在輸入檔案以大端格式儲存幷包含 strL 資料時引發 KeyError 的錯誤 (GH 58638)
read_stata() 在格式版本 111 及更早版本中,極端值整數被錯誤地解釋為缺失值的錯誤 (GH 58130)
read_stata() 在格式版本 105 及更早版本中,雙精度型別的缺失碼未被識別的錯誤 (GH 58149)
set_option() 將 pandas 選項 display.html.use_mathjax 設定為 False 無效的錯誤 (GH 59884)
to_excel() 在 passing merge_cells=False 時,MultiIndex 列被合併到單行的錯誤 (GH 60274)
Period#
繪圖#
DataFrameGroupBy.boxplot() 在存在多個分組時失敗的錯誤 (GH 14701)
DataFrame.plot.bar() 在使用 subplots 和 stacked=True 時堆疊不正確的錯誤 (GH 61018)
DataFrame.plot.bar() 在 stacked=True 時,具有零高度段的堆疊條上的標籤被錯誤地放置在底部,而不是前一個段的標籤位置的錯誤 (GH 59429)
DataFrame.plot.line() 在同時設定 color 和 dict 樣式時引發 ValueError 的錯誤 (GH 59461)
DataFrame.plot() 在頻率乘數大於一時,會向右移動的錯誤 (GH 57587)
DataFrame.plot() 在繪製每個子圖多於一列時,title 需要額外標題的錯誤 (GH 61019)
Series.plot() 阻止在同一圖上對齊線圖和條形圖的錯誤 (GH 61161)
Series.plot() 阻止對齊線圖和散點圖的錯誤 (GH 61005)
Series.plot() 在 kind="pie" 與 ArrowDtype 一起使用時的錯誤 (GH 59192)
繪製具有非納秒解析度的 TimedeltaIndex 時,顯示不正確標籤的錯誤 (GH 63237)
Groupby/resample/rolling#
DataFrameGroupBy 縮減中,numeric_only 引數允許非布林值,現在傳遞非布林值將引發錯誤的錯誤 (GH 62778)
DataFrameGroupBy.__len__() 和 SeriesGroupBy.__len__() 在分組包含 NA 值且 dropna=False 時會引發錯誤的錯誤 (GH 58644)
DataFrameGroupBy.agg() 和 SeriesGroupBy.agg() 在輸入值為 pyarrow dtype 時返回 numpy dtype 值的錯誤,而不是返回 pyarrow dtype 值 (GH 53030)
DataFrameGroupBy.agg() 在存在字典輸入和重複列時引發 AttributeError 的錯誤,而不是返回聚合了所有重複列的 DataFrame (GH 55041)
DataFrameGroupBy.agg() 在將使用者定義的函式應用於空 DataFrame 時返回 Series 而不是空 DataFrame 的錯誤 (GH 61503)
DataFrameGroupBy.any() 在其中所有 Timedelta 值都是 NaT 的組返回 True 的錯誤 (GH 59712)
DataFrameGroupBy.apply() 和 SeriesGroupBy.apply() 在 group_keys=False 的空 DataFrame 上,仍使用組鍵建立輸出索引的錯誤 (GH 60471)
DataFrameGroupBy.apply() 和 SeriesGroupBy.apply() 未保留子類化 DataFrame 和 Series 的 _metadata 屬性的錯誤 (GH 62134)
DataFrameGroupBy.apply() 在 func 的所有返回值都為 None 時返回完全為空的 DataFrame,而不是返回具有原始列和 dtype 的空 DataFrame 的錯誤 (GH 57775)
DataFrameGroupBy.apply() 在 as_index=False 時返回 MultiIndex 而不是 Index 的錯誤 (GH 58291)
DataFrameGroupBy.cumsum() 和 DataFrameGroupBy.cumprod() 中,numeric_only 引數透過 kwargs 間接傳遞而不是直接傳遞的錯誤 (GH 58811)
DataFrameGroupBy.cumsum() 在標籤包含 None 時未返回正確 dtype 的錯誤 (GH 58811)
DataFrameGroupBy.groups() 和 SeriesGroupBy.groups() 不遵守 groupby 引數 dropna 的錯誤 (GH 55919)
DataFrameGroupBy.groups() 和 SeriesGroupBy.groups() 在組是包含 NA 值的 Categorical 時失敗的錯誤 (GH 61356)
DataFrameGroupBy.median() 中 NaT 值導致結果不正確的錯誤 (GH 57926)
DataFrameGroupBy.quantile() 在 interpolation="nearest" 時與 DataFrame.quantile() 不一致的錯誤 (GH 47942)
DataFrameGroupBy.sum() 和 SeriesGroupBy.sum() 在溢位時返回 NaN 的錯誤。現在這些方法在溢位時返回 inf 或 -inf (GH 60303)
DataFrameGroupBy.transform() 和 SeriesGroupBy.transform() 在使用 reducer 和 observed=False 時,當存在未觀察到的類別時,會將 dtype 強制轉換為 float 的錯誤 (GH 55326)
Resampler.asfreq() 在具有 origin 的固定頻率索引時忽略對齊並返回錯誤值的錯誤。現在 origin 和 offset 會被尊重 (GH 62725)
Resampler.interpolate() 在具有非均勻取樣和/或索引與結果重取樣索引不對齊的 DataFrame 上時,會導致錯誤的插值的錯誤 (GH 21351)
Rolling.apply() 在 method="table" 時,由於列預設按排序,未保留列順序的錯誤 (GH 59666)
Rolling.apply() 在 method="table" 時,應用於函式的週期數可能少於 min_period 的錯誤 (GH 58868)
Rolling.sem() 由於除以 sqrt((n - 1) * (n - ddof)) 而不是 sqrt(n * (n - ddof)),導致計算結果不正確的錯誤 (GH 63180)
Series.rolling() 與 BaseIndexer 子類一起使用並計算 min/max 時出錯的錯誤 (GH 46726)
DataFrame.ewm() 和 Series.ewm() 在 passed times 和非 mean 的聚合函式時的錯誤 (GH 51695)
DataFrame.resample() 和 Series.resample() 在索引具有 ArrowDtype 時間戳 dtype 時,未能保留索引名稱的錯誤 (GH 61222)
DataFrame.resample() 在 DataFrame 為空並使用 upsample 方法時,將索引型別更改為 MultiIndex 的錯誤 (GH 55572)
Rolling.skew() 和 Rolling.kurt() 由於數值不穩定性,在視窗跟隨異常值時錯誤地計算偏度和峰度(分別)的錯誤。現在計算會透過重新計算受影響的視窗來正確處理災難性取消 (GH 47461, GH 61416)
Rolling.skew() 和 Rolling.kurt() 在結果與輸入長度變化但資料和視窗內容相同的情況下,結果出現差異的錯誤 (GH 54380)
Series.resample() 在日期範圍結束於不存在的時間點之前不久時可能引發錯誤的錯誤 (GH 58380)
Series.resample() 在對非納秒解析度進行越界重取樣(納秒精度)時引發錯誤的錯誤 (GH 57427)
Rolling.var() 和 Rolling.std() 由於數值不穩定性而計算結果不正確的錯誤 (GH 47721, GH 52407, GH 54518, GH 55343)
DataFrame.groupby() 方法在操作 NumPy 可空資料時,當 NA 掩碼不是 C 連續時失敗的錯誤 (GH 61031)
DataFrame.groupby() 在按 Series 分組,並且該 Series 在呼叫 DataFrame.groupby() 後但在 groupby 操作之前被修改時出現錯誤的 (GH 63219)
DataFrame.groupby() 使用 TimeGrouper(例如 pd.Grouper(freq="D"))時,未能保留 PyArrow 索引 dtype 的錯誤 (GH 63518)
Reshaping#
concat() 在混合整數和布林 dtype 時,錯誤地將布林值轉換為整數的錯誤 (GH 45101)
qcut() 在分位數邊界處的值可能被錯誤分配的錯誤 (GH 59355)
DataFrame.combine_first() 未保留列順序的錯誤 (GH 60427)
DataFrame.combine_first() 在具有非唯一列時錯誤地引發異常的錯誤 (GH 29135)
DataFrame.combine() 在具有非唯一列時錯誤地引發異常的錯誤 (GH 51340)
DataFrame.explode() 對 pyarrow.large_list 型別產生錯誤結果的錯誤 (GH 61091)
DataFrame.join() 在不一致地設定結果索引名稱的錯誤 (GH 55815)
DataFrame.join() 在與 Series/DataFrames 列表進行連線時,未產生正確的行順序的錯誤 (GH 62954)
DataFrame.join() 在 DataFrame 具有 MultiIndex 且 MultiIndex.names 包含 None 時引發 AssertionError 的錯誤 (GH 58721)
DataFrame.merge() 在按僅包含 NaN 值的列進行合併時,導致陣列越界訪問的錯誤 (GH 59421)
Series.combine_first() 錯誤地將 None 條目替換為 NaN 的錯誤 (GH 58977)
DataFrame.unstack() 在 sort=False 時產生錯誤結果的錯誤 (GH 54987, GH 55516)
DataFrame.unstack() 在索引包含 NaN 且 sort=False 時引發錯誤的錯誤 (GH 61221)
DataFrame.merge() 在 Windows 上合併兩個 intc 或 uintc 型別的 DataFrame 時出現錯誤的 (GH 60091, GH 58713)
DataFrame.pivot_table() 在未提供 index 引數時,錯誤地對結果進行了子聚合(GH 58722)
DataFrame.pivot_table() 在同時提供 values 引數給 index 或 columns 引數時,錯誤地忽略了 values 引數(GH 57876, GH 61292)
DataFrame.pivot_table() 的 margins=True 在明確傳遞 dropna=False 時,沒有正確包含索引或列中具有 NaN 值的組(GH 61509)
DataFrame.stack() 在 future_stack=True 時,當 level=[] 時引發 ValueError 的錯誤(GH 60740)
DataFrame.unstack() 在處理具有 ExtentionDtype 的空 DataFrame 時,產生錯誤結果(GH 59123)
concat() 在將 DataFrame 和 Series 與 ignore_index=True 連線時,會丟失 Series 的名稱(GH 60723, GH 56257)
melt() 在 id_vars 中包含重複列名時,引發了誤導性的 AttributeError(GH 61475)
DataFrame.merge() 在同時指定 right_on 和 right_index 時,如果也指定了 left_on,則沒有引發 MergeError。現在這種情況會引發 MergeError。(GH 63242)
DataFrame.merge() 在使用者提供的字尾可能導致生成的名稱與現有列匹配從而產生重複列名的情況下,現在會引發 MergeError。(GH 61402)
DataFrame.merge() 在與 CategoricalDtype 列一起使用時,錯誤地引發了 RecursionError(GH 56376)
DataFrame.merge() 在使用 float32 索引時,錯誤地將索引轉換為 float64(GH 41626)
Sparse#
SparseDtype 在與 na fill value 進行相等比較時存在錯誤。(GH 54770)
DataFrame.sparse.from_spmatrix() 在某些子型別中硬編碼了無效的 fill_value。(GH 59063)
DataFrame.sparse.to_dense() 忽略了子類化,總是返回 DataFrame 例項(GH 59913)
SparseArray.cumsum() 在處理整數資料時,導致最大遞迴深度錯誤。(GH 62669)
ExtensionArray#
arrays.ArrowExtensionArray.__setitem__() 在使用具有重複值的整數陣列作為鍵時,行為不正確(GH 58530)
ArrowExtensionArray.factorize() 在輸入是字典編碼時,即使 dropna 設定為 False,也會丟棄 NA 值(GH 60567)
NDArrayBackedExtensionArray.take() 在使用整數陣列呼叫時,產生 dtype 與底層資料不匹配的陣列(GH 62448)
api.types.is_datetime64_any_dtype() 在自定義 ExtensionDtype 物件上,對於 array-like 會返回 False(GH 57055)
Arrow 支援的持續時間和時間戳的縮減(例如 sum、min、max、median、mean)在解析度不是納秒時,錯誤地返回 stdlib datetime 物件,而不是 Timedelta 和 Timestamp。(GH 63170)
ArrowDtype 物件與不相容型別(例如字串 vs 布林值)的比較,錯誤地引發異常,而不是返回全 False(對於 ==)或全 True(對於 !=)(GH 59505)
在 PyArrow 未安裝時,透過 dtype 字串加上 "[pyarrow]" 來構造 pandas 資料結構,會引發 NameError 而不是 ImportError(GH 57928)
各種 DataFrame 縮減操作在 pyarrow 時間型別中,當結果為 null 時,返回了錯誤的 dtype(GH 59234)
在傳遞 fill_value 時,ExtensionArray 運算元之間的 flex arithmetic 出現錯誤。(GH 62467)
Styler
Styler.to_latex() 在樣式化列標題並結合隱藏索引或隱藏索引級別時存在的問題已修復。
其他#
DataFrame 在傳遞包含 NA 標量和 columns 的 dict 時,總是返回 np.nan(GH 57205)
Series 在嘗試將 Series 輸入資料轉換為給定 dtype 時,忽略了錯誤(GH 60728)
eval() 在 ExtensionArray 上執行除法 / 操作時,由於 TypeError 而失敗。(GH 58748)
eval() 在對二進位制操作(如 (x + y).dropna())進行方法呼叫時,引發了 AttributeError: 'BinOp' object has no attribute 'value'(GH 61175)
eval() 在使用 engine="numexpr" 時,未保留 Series 的名稱。(GH 10239)
eval() 在使用 engine="numexpr" 時,浮點除法返回了意外的結果。(GH 59736)
to_numeric() 在 arg 為 Timedelta 或 Timestamp 標量時,引發了 TypeError。(GH 59944)
unique() 在 Index 上時,不總是返回 Index。(GH 57043)
DataFrame.apply() 在傳遞 func=list[int] 時,引發了 RecursionError。(GH 61565)
DataFrame.apply() 在傳遞 engine="numba" 時,忽略了傳遞給應用函式的 args(GH 58712)
DataFrame.eval() 和 DataFrame.query() 在使用 @ 符號表示法透過 NumPy 屬性(例如,df.eval("@np.floor(a)"))時,導致了異常。(GH 58041)
DataFrame.eval() 和 DataFrame.query() 不支援使用 tan 函式。(GH 55091)
DataFrame.groupby() 在使用 None 值進行過濾時存在問題(GH 62501)
DataFrame.query() 在使用重複列名時導致了 TypeError。(GH 59950)
DataFrame.query() 在表示式包含反引號括起來的包含雜湊字元 #、反引號或不在 ASCII 範圍內的字元(U+0001..U+007F)的列名時,會引發異常或產生錯誤的結果。(GH 59285)(GH 49633)
DataFrame.query() 在使用反引號查詢整數列名時,會引發異常。(GH 60494)
DataFrame.rename() 和 Series.rename() 在傳遞的 mapper、index 或 columns 引數是具有非唯一 ser.index 的 Series 時,會產生損壞的結果而不是引發 ValueError。(GH 58621)
DataFrame.sample() 在 replace=False 且 (n * max(weights) / sum(weights)) > 1 的情況下,會返回有偏差的結果。現在會引發 ValueError。(GH 61516)
DataFrame.shift() 在沒有列的 DataFrame 上傳遞 freq 時,索引未正確移動。(GH 60102)
DataFrame.sort_index() 在傳遞 axis="columns"、ignore_index=True 和 ascending=False 時,未返回 RangeIndex 列。(GH 57293)
DataFrame.sort_values() 在按顯式命名為 None 的列排序時,引發了 KeyError,而不是按預期排序。(GH 61512)
DataFrame.transform() 返回的順序不正確,除非索引是單調遞增的。(GH 57069)
DataFrame.where() 在使用非布林型別陣列時,返回了 ValueError 而不是 TypeError(GH 56330)
Index.sort_values() 在傳遞將值轉換為元組的鍵函式(例如 key=natsort.natsort_key)時,會引發 TypeError(GH 56081)
Series.describe() 在傳遞 percentiles 引數時,始終包含中位數百分位數。(GH 60550)。
Series.diff() 允許 periods 引數接收非整數值。(GH 56607)
Series.dt() 在 ArrowDtype 中使用時,方法返回了不正確的值。(GH 57355)
Series.isin() 在 Series 較大(>10**6)且 values 包含 NA 時,引發了 TypeError(GH 60678)
Series.kurt() 和 Series.skew() 在低方差陣列上結果為零(GH 57972)
Series.list() 訪問器方法未保留原始 Index。(GH 58425)
Series.list() 訪問器方法未保留原始名稱。(GH 60522)
Series.map() 在使用 timestamp[pyarrow] dtype 或 duration[pyarrow] dtype 時,錯誤地返回了全 NaN 條目(GH 61231)
Series.mode() 在對具有可空型別且 series 中沒有 null 值的 Series 取模式時,引發了異常。(GH 58926)
Series.rank() 在 na_option='keep' 時,未保留可空整數的缺失值。(GH 56976)
Series.replace() 和 DataFrame.replace() 在 regex=True 且所有值都為 NA 時,丟擲了 ValueError。(GH 60688)
Series.replace() 在 Series 從 Index 建立且啟用了 Copy-On-Write 時存在問題(GH 61622)
Series.to_string() 在 series 包含帶有指數的複數浮點數時存在問題(GH 60405)
DataFrame Interchange Protocol 實現,在字串和日期時間列的資料緩衝區相關 dtype 時,返回了不正確的結果(GH 54781)
DataFrame、Series 和 Index 的 divmod 和 rdivmod 操作,在 bool dtypes 上未能引發異常,這與 __floordiv__ 的行為不一致(GH 46043)
列印包含儲存在 DataFrame.attrs 中的 DataFrame 的 DataFrame 時,引發了 ValueError(GH 60455)
列印包含儲存在 Series.attrs 中的 DataFrame 的 Series 時,引發了 ValueError(GH 60568)
在對 DataFrame 或 Series 呼叫 copy.copy() 時,返回的是深複製而不是淺複製(GH 62971)
Series.rank() 在物件 dtype 和極小的浮點值情況下存在的問題已修復。(GH 62036)
DataFrame 建構函式錯誤地將帶有 .name 屬性的 array-like 物件分類為 Series 或 Index 的問題已修復(GH 61443)
訪問 DataFrame 或 Series 的底層 NumPy 陣列時,如果陣列與原始 DataFrame 或 Series 共享資料,則會返回一個只讀陣列(只讀 NumPy 陣列)。此邏輯已透過
.array(或根據 dtype 不同而為.values)擴充套件到訪問底層的 pandas ExtensionArray(GH 61925)。
貢獻者#
共有 729 人為本次釋出貢獻了補丁。名字旁邊有“+”號的人是第一次貢獻補丁。
121238257 +
3w36zj6 +
ADITYA KUSHWAHA +
ADITYA V J +
Abby VeCasey +
Abdulaziz Aloqeely
Abel Sanchez +
Abel Tavares +
Abhijit Chakraborty +
Abhinav +
Abhinav Reddy +
Abhinav Thimma +
Abhishek Chaudhari +
Abkari Mohammed Sayeem +
Aditya Ghosh +
Aditya Jha +
Aditya060 +
Agriya Khetarpal +
Ahmed Khairy +
Aidan Feldman
Aidos Kanapyanov
Akashisang +
Akshay Jain +
Albert Villanova del Moral
Alex
Alex Malins
Alexey Murz Korepov +
Alfredo Carella +
Alp +
Aman Sharma +
Amey Shinde +
Amin Allahyar +
Amir +
Amy Fung +
AnaDenisa +
Anand Mukherjee +
Andre Correia +
AndreyKolomiets +
André +
Andy
Angela Liss +
Aniket
Animcogn +
Anish Karki +
Anish Karthik +
Ankit Dhokariya +
Annika +
Anthony Speicher +
Antonio Valentino +
Antriksh006 +
Anurag Varma +
Aokizy2 +
Apoorv +
Arthur Laureus Wigo +
Arthur Wigo +
Artur Kenzo Obara Kawazoe +
Aryn1102 +
Ashar Khan +
Asish Mahapatra
Augustus +
Austin +
Austin Rhodes +
AustinOregonState +
Axeldnahcram +
Benjamin M +
Biplav Barua +
Borja Elizalde +
Brandon Norton +
Brandon Xu +
BreezeLune +
Brett Dixon +
Brian Christian +
Brian M +
Caden Gobat +
CaesarTY +
Carlo Barth +
Carson Fox +
Chaarvi Bansal +
ChiLin Chiu
Chris
Chris Hewitt +
Chris Xiang +
Christian Bläul +
Christian Castro +
Christine P. Chai +
Christopher Horn, PhD +
Christopher Titchen +
Christopher Xiang +
Claude Opus 4.5 +
Cliff Kerr +
Clément Robert
Code_Blooded +
Connor Wallace +
Cornelius Roemer +
Cristiano Sampaio +
Cristina Yenyxe Gonzalez Garcia +
DL Lim +
Dan Lawson +
Danferno +
Daniel Pinto Salazar +
Daniel S +
Dave Bunten +
Dave Tapley +
David Carvalho +
David Krych
Davit Gyulnazaryan +
DaxServer +
Dea María Léon
Deekshita +
Deen-dot +
Deepak Kapila +
Deepak Saldanha +
Denis Karadaş +
Denis Matsiusheuski +
Derek M. Knowlton +
Dhruv B Shetty
Dinesh Dawonauth +
Dipanshi Bansal +
Divya Sharma +
Dmitry Korotaev +
Dominik Smrž +
Echedey Luis +
Eduard Akhmetshin +
Edward FANG +
Ehsan Totoni +
Elliott Sales de Andrade
EngSongYeong +
Enrico Massa +
Eric Brown +
Eric Chen +
Eric Larson +
Espoir Murhabazi +
Ethan V Van Hao +
Eve Loraine Nuñal +
Evgenii Mosikhin
Ewout ter Hoeven
FLOURA ANGEL +
Fandi Meng +
Fangchen Li
Farsidetfs +
Fawaz Ahmed +
Fidorc80 +
Flavia Y. Ouyang +
Florian Bourgey +
Florian Jetter
Francesco Bruzzesi +
Francisco Kurucz +
Frank +
French_Ball +
FuzzyParrabellum +
G Karthik Koundinya +
Gael Varoquaux +
GauravM +
Geeeeeene +
Gen Sato +
George He +
Georgina Scott +
Georgios Giannakoulias +
Georgios Malandrakis +
Gianluca Ficarelli
Gleb Khmyznikov +
Goutham Anand +
Gowtham Kumar K. +
Grant Garrett-Grossman +
Gregers Thomas Skat Rørdam +
Guilherme Martins Crocetti +
GuruprashanthKrishnakumar +
Hanxin Chen +
Hariharan P R +
Harini Krishnamurthy +
Harmen Stoppels +
Harsha Lakamsani +
Harshit Pande +
Hassan Rad +
Henry Cuzco +
HeoHeo +
Hongxu Jia +
Hridey Marwah +
Huanghz2001
Huilin Xu +
HuilinXu +
HulusiOzy +
Ian Thompson +
Iaroslav Igoshev +
Icaro Alves +
Ilya +
Ingo Stallknecht +
Irv Lustig
Isaac Virshup
Isuru Fernando
Ivruix +
JBurley +
JHM Darbyshire
JJLLWW +
Jack +
Jack Shewring +
JackCollins1991 +
JackCollins91
Jacob Eggerd +
Jacob Lazar +
Jake Thomas Trevallion
Jakob Zahn +
Jakub Błażejowski +
Jakub Raczyński +
Jakub Szkliniarz +
James Bourbeau
James Spencer
James Yuill +
Janez Demšar +
JaniceP +
Jason Mok +
Javier Marin Tur +
Jay
Jay Ahn +
Jayalakshmi M +
Jean K. +
Jeff Harrison +
Jennifer Benson +
Jeremy Tuloup
Jesse +
Jixun Sun +
John Hendricks +
John Paul Feliciano +
Jonas Bergner +
Jonathan Marriott +
Jonathan Reimer +
Jordan Murphy +
Joren Hammudoglu +
Joris Van den Bossche
Joseph Kleinhenz +
Josquin Larsen +
José Morales +
JuanCarlos3 +
Julian Harbeck +
Julian-Harbeck +
Julien Palard
JulienBacquart +
Justine Wezenaar +
Kamel Gazzaz +
Karen Javadyan +
Karl Tarbet +
Katsia +
Kei +
KeiOshima +
Kevin Amparado
Kevin Doshi +
Kevin Sheppard
Kevon Scott +
Khemkaran
Khemkaran Sevta
Khor Chean Wei
Kian Eliasi
Kiril Isakov +
Kirill +
Konstantin Malanchev +
Korotaev DV +
Kunal Jani +
Kushagr Arora +
LOCHAN PAUDEL
Lakshman +
Lakshya Upadhyaya +
Laurent Mutricy
Laurie O
Leo Gordon +
Lex Lei +
Li +
Lirong +
Lobna Allam +
Loic Diridollou
Lonercode +
Louis Maddox +
Loïc Estève
Lu Yibo +
Luke Manley
Lysandros Nikolaou
Maaz Bin Asif +
Maitrey Talware +
Mangesh Kashid +
Manish Ranjan Karna +
Manjunath L +
Manlai Amar +
Marc Garcia
Marc Jones +
Marc Mueller
Marco Aurélio A. Barbosa +
Marco Barbosa +
Marco Edward Gorelli
Marco Gorelli
MarcoGorelli
Maren Westermann
Maria Ivanova +
Mark Akritas +
Mark Bekooy +
Mark Ryan +
Martin Braquet +
Mateusz Sokół
Matt Braymer-Hayes
Matt Delengowski +
Matt Heeter +
Matt Page +
Matt Popovich +
Matteo Paltenghi +
Matthew Heguy +
Matthew Pak +
Matthew Roeschke
Matthew Simpson +
Matthieu Thiboust +
Maushumee +
Maximilian Nicholson +
Meet_Vasita +
Memoona Shah +
Michael
Michael Hu +
Michael Moyles +
Michael Vincent Mannino +
Michaël Defferrard +
Michał Górny
Michelino Gali +
Michiel De Muynck +
Mien (Josephine) Nguyen +
Miguel Cárdenas +
Mika Allert +
Mike Perrone +
Mohammad Ahmadi
Moshe Kaplan +
Movsisyan +
Myles Scolnick +
Naresh Kumar +
Natalia Mokeeva
Natalie Dettmer +
Nathan Goldbaum
Navya Srivastava +
NewUserHa +
Nick Crews
Nikhil +
Niklas Rousset +
Niruta Talwekar +
Nithurshen +
Nitish Satyavolu +
Noa Tamir
Noah Asing +
Nrezhang +
Olivier H. +
PRANAV +
Parthava Adabala +
Parthi
Pascal Brochart +
Pascal Corpet +
Patrick Hoefler
Paul
Paul Behrisch +
Paul Bissex +
Paulo S. Costa
Pedro Diogo +
Pedro Freitas +
Pedro Marques +
Pedro Santos +
PenguinPen +
Peter Nguyen +
Peter Westling +
Petroncini +
Philipp Hoffmann +
Pol Rius +
Praateek Mahajan +
Pranav Raghu +
Pranav Wadhwa +
Prathamesh +
Preetham Yerragudi +
Qaiser Abbasi +
Quang Nguyễn
Quentin Lhoest +
Rafael Fontenelle +
Raffi Enficiaud +
Rajvi Gemawat +
Ralf Gommers
Randolf Scholz
Richard Howe +
Richard Shadrach
Ritoban Dutta +
Ritwiz Sinha +
Rob
Robert Schmidtke
Robert Utterback +
Robert Wolff +
Robin
Robin Mader +
Robin Shindelman +
Rohan Jain
Roline Stapny Saldanha +
Ron Arbo +
Rui Amaral +
Ruifeng Zheng +
Rustam Ali +
Rutrum +
S +
SAHARSH TIBREWALA +
SALCAN
Saadha Salim +
Sam Baumann +
Samuel +
Samuel Chai
Samuel Oranyeli
Samuel Xavier +
Sanchit Rishi +
SanchitD +
Sangam Paudel +
Sanjana Moudgalya +
Santhosh Kumar Bethi +
Saraswathy Kalaiselvan +
Sathvik Mulukutla +
Scott Talbert
Sebastian Berg
Sebastian Correa +
SebastianOuslis +
Sergey B Kirpichev +
Sergio Livi +
Shabab Karim
Shashwat Agrawal
ShaunSrirangam +
Shawn Liu +
Shi Entong +
Shing Chan +
Shmulik Cohen +
Shreyal Gupta +
Shreyas +
Shubham Sarkar +
Shubhang Sinha +
Shubhank Gyawali +
Shubhankar Agrawal +
Siddhesh Bangar +
SiemBerhane +
Simon Hawkins
Sinclair Hudson +
Sivasweatha Umamaheswaran +
Sofia Soares +
Sparsh Sah +
Sreeja Govardhana +
Srinitya Kondapally +
Stefano Silvestri +
Steffen Rehberg
Stepfen Shawn
Steven Schaerer
SubsequentlySneeds +
Suhrid Singh +
Sukriti +
Sumeet Bhatnagar +
Swati Sneha +
T. Koskamp +
TJ +
Tal yahav +
Tanya Bouman +
TechnoShip123 +
Tejas Rajput +
Tejaswini V +
TessAfanasyeva +
Thad Guidry +
Thai Villaluna +
Thanh Lam DANG +
Thanh Le-Cong +
Thi PHAN +
Thierry Moisan
Thomas A Caswell
Thomas Baumann
Thomas Dixon +
Thomas H
Thomas Heavey
Thomas Holder +
Thomas Li
Thomaz +
Thomaz Miranda +
Thummalapalli Sai Teja Sri Sanjana +
Tiffany Xiao +
Tilova Shahrin +
Tim Hoffmann
Tim Smith +
Tim Sweña (Swast) +
Tim Yang
Tirthraj Parmar +
Tolker-KU
Tom Augspurger
Tomaz Silva +
Tonow +
Torsten Wörtwein
Trevor Serrao +
Trinh Quoc Anh
Tristan Koskamp +
Tuhin Sharma +
Tunahan Yardımcı +
Tyson Cung +
U-S-jun +
UDIT BALIYAN +
UV +
Udit Baliyan +
Ulrich Dobramysl +
VISWESWARAN1998 +
Valentin Iovene
Veit Heller +
Venkat +
Venkata Akhil Mettu +
Vibavari Gurunathan +
Vignesh Iyer +
Vijay Sarathy +
Vikram Kumar +
Vineet Kumar +
Vishal Shivam +
Viswa Sai Ammiraju Bonam +
Vladimir Fokow
Vrashank Shetty +
W. H. Wang +
Wang Haoxiang +
Wei-Hsiang (Matt) Wang +
Wes Turner
WhimsyHippo +
Will Sorenson +
William Andrea
William Ayd
William Joshua King +
William King +
Winnie +
Wong2333 +
Work +
XY +
Xiao Yuan
Y.X +
Yana Mishula +
Yashpal Ahlawat +
Yassin Abdelghany +
Yaswanth Kumar +
Yi-Fan Wang +
Yi-Han Chen +
Yinon Horev +
YinonHorev +
Yoshimu U. Nats +
Yuki Kitayama
Yuki Kobayashi +
Yuri Batista Ishizawa +
Yuvraj Pradhan +
ZA1815 +
ZKaoChi +
Zachary Collins +
Zanir Pirani +
ZanirP +
Zephy +
Zhengbo Wang
Zorex Salvo +
Zrahay +
[Annika Rudolph] +
aBiR1D +
aaron-robeson-8451
aaronchucarroll +
abonte
ahmedbektic +
aimlnerd +
amansharma612 +
ammar-qazi +
ananiavito +
anishkarki +
anzber +
aokizy +
aram-cinnamon
asoledad33 +
auderson
avecasey +
averagejoy +
avm19 +
aydinkhan2005 +
bdwzhangumich +
benjamindonnachie +
bluestarunderscore +
callumfrederiksen +
calvin +
chaoyihu +
chen +
chi +
cloudboat +
cmjcharlton +
cmp0xff +
cristian_scobioala +
dajale423 +
datapythonista +
davidesquer +
dependabot[bot]
devin-ai-integration[bot] +
dkane01 +
droussea2001 +
dshettyepi +
dsousa +
easternsun7 +
eicchen +
eicchen02 +
eightyseven +
eilonc-cx +
ellaella12 +
ensalada-de-pechuga +
er-eis +
erichxchen +
eshaready +
fatslow +
gabuzi +
gameofby +
gboeker +
hafeja +
haffara +
harinik +
huhu +
huisman +
hye ryung cho +
iangainey +
ianlv +
igeni +
imTejasRajput +
invain01 +
invalidarg +
ivanpan0626 +
ivonastojanovic +
jad +
james-magee +
jarent-nvidia +
jayendhargautham +
jbrockmendel
jeffersbaxter +
jeffery nosakhare Omorodion +
jeffreykenneth +
jerrywbirnbaum +
jgao8 +
jl_win_a +
jmalp +
jmarin +
johnff9 +
johnpaulfeliciano98 +
johnyu013 +
jrmylow +
justmhie +
jzwick +
karnbirrandhawa +
koushik-rout-samsung +
kpvenkat47 +
krishna datta +
ktseng4096 +
lamprinikourou +
lfffkh +
lif +
llayague +
mateomramos +
matiaslindgren +
matsidzi +
mattbest +
mazhar996 +
messense +
microslaw +
mikkas456 +
morotti
mroeschke * DOC: fix example for iv_idx.left * Implement test for GH #21340 * minor fixup * Lint contribution * Make spacing consistent * Lint * Remove duplicate column construction * Avoid DeprecationWarning by setting include_groups=False in apply ——— Co-authored-by: Jason Mok +
mroeschke +
musvaage +
mutricyl +
myenugula +
ncknelson +
ofsouzap +
omahs +
ooo oo +
pandas Development Team
partev
paul +
pedrocariellof +
pre-commit-ci[bot]
ptth222
r0rshark +
rdzantoine.pro@gmail.com +
renanffernando +
rhshadrach
richard +
ritwika314 +
rmorotti +
rohanjain101
root +
s1099 +
sah0725 +
santhoshbethi +
sdhjebngc +
sharkipelago +
shriyakalakata +
sjalkote +
skalwaghe_56 +
sliuos +
sooooooing +
specialkapa +
sshu2017 +
steeleelliott03 +
stevenae +
sunlight +
surenpoghosian +
suzyahyah +
taranarmo +
tasfia8
tharun-mk +
thetestspecimen +
thomasdamcevski +
thwait +
tisjayy +
tomas-cc +
u7397058 +
undermyumbrella1 +
v-lozko +
veljanin +
viable-alternative +
wanglc02 +
wdyy20041223 +
wenchen-cai +
william larkin +
wooseogchoi +
wysiwyg +
xiaohuanlin +
xingyubobo33333 +
xxx.Yan +
yashb
yjennyli +
yokomotod +
zachyattack23 +
zhan7236 +
zhiqiangxu +
zishan044 +
zjweiss-google +
zslsally +
Álvaro Kothe
Óscar Gómez +
張博聞 +
許知恆 +
🍌Shawn +