2.2.1 版本的新特性 (2024 年 2 月 22 日)#
这是 pandas 2.2.1 版本中的变化。有关包括其他 pandas 版本在内的完整更新日志,请参阅版本说明。
增强功能#
添加了
pyarrow
pip extra,用户可以使用pip install pandas[pyarrow]
通过 pip 安装 pandas 和 pyarrow (GH 54466)
修复的回归问题#
修复了
read_csv()
中的内存泄漏问题 (GH 57039)修复了
Series.combine_first()
中的性能回归问题 (GH 55845)修复了导致接近最小时间戳溢出的回归问题 (GH 57150)
修复了
concat()
中的回归问题,该问题改变了当轴是DatetimeIndex
时始终对非连接轴进行排序的长期行为 (GH 57006)修复了
merge_ordered()
在fill_method="ffill"
和how="left"
时引发TypeError
的回归问题 (GH 57010)修复了
pandas.testing.assert_series_equal()
在检查Index
时默认为check_exact=True
的回归问题 (GH 57067)修复了
read_json()
中的回归问题,该问题会返回Index
而不是RangeIndex
(GH 57429)修复了
wide_to_long()
在处理字符串列时引发AttributeError
的回归问题 (GH 57066)修复了
DataFrameGroupBy.idxmin()
、DataFrameGroupBy.idxmax()
、SeriesGroupBy.idxmin()
和SeriesGroupBy.idxmax()
忽略skipna
参数的回归问题 (GH 57040)修复了
DataFrameGroupBy.idxmin()
、DataFrameGroupBy.idxmax()
、SeriesGroupBy.idxmin()
和SeriesGroupBy.idxmax()
中的回归问题,其中包含该 dtype 的最小值或最大值的值可能会产生错误结果 (GH 57040)修复了
CategoricalIndex.difference()
在 other 包含除 NaN 之外的空值时引发KeyError
的回归问题 (GH 57318)修复了
DataFrame.groupby()
在某些情况下按Series
分组时引发ValueError
的回归问题 (GH 57276)修复了
DataFrame.loc()
对于结果行数超过 10,000 行的非唯一、掩码 dtype 索引引发IndexError
的回归问题 (GH 57027)修复了
DataFrame.loc()
中的回归问题,该问题在使用部分行索引和多列进行扩展时,会不必要地抛出“不兼容的 dtype 警告”(参见 PDEP6) (GH 56503)修复了
DataFrame.map()
中带有na_action="ignore"
参数的回归问题,该参数对于 NumPy nullable 和ArrowDtypes
不生效 (GH 57316)修复了
DataFrame.merge()
对于某些类型的第三方扩展数组引发ValueError
的回归问题 (GH 57316)修复了
DataFrame.query()
在处理 object dtype 且全为NaT
的列时的回归问题 (GH 57068)修复了
DataFrame.shift()
在axis=1
且DataFrame
为空时引发AssertionError
的回归问题 (GH 57301)修复了
DataFrame.sort_index()
对于带有重复项的索引无法生成稳定排序的回归问题 (GH 57151)修复了
DataFrame.to_dict()
在使用orient='list'
且数据类型为 datetime 或 timedelta 时返回整数的回归问题 (GH 54824)修复了
DataFrame.to_json()
将可空整数转换为浮点数的回归问题 (GH 57224)修复了
DataFrame.to_sql()
在传递method="multi"
且数据库方言类型不是 Oracle 时出现的回归问题 (GH 57310)修复了
DataFrame.transpose()
在处理不具有 F-contiguous 数据格式的可空扩展 dtype 时可能导致异常的回归问题 (GH 57315)修复了
DataFrame.update()
发出关于向下转型的不正确警告的回归问题 (GH 57124)修复了
DataFrameGroupBy.idxmin()
、DataFrameGroupBy.idxmax()
、SeriesGroupBy.idxmin()
和SeriesGroupBy.idxmax()
忽略skipna
参数的回归问题 (GH 57040)修复了
DataFrameGroupBy.idxmin()
、DataFrameGroupBy.idxmax()
、SeriesGroupBy.idxmin()
和SeriesGroupBy.idxmax()
中的回归问题,其中包含该 dtype 的最小值或最大值的值可能会产生错误结果 (GH 57040)修复了
ExtensionArray.to_numpy()
对于非数值掩码 dtype 引发异常的回归问题 (GH 56991)修复了
Index.join()
在将空索引与包含混合 dtype 值的非空索引连接时引发TypeError
的回归问题 (GH 57048)修复了
Series.astype()
在将带有缺失值的整数转换为字符串 dtype 时引入小数点的回归问题 (GH 57418)修复了
Series.pct_change()
对于空Series
引发ValueError
的回归问题 (GH 57056)修复了
Series.to_numpy()
在 dtype 为 float 且数据包含 NaNs 时出现的回归问题 (GH 57121)修复了将带有毫秒分量的
DateOffset
对象添加到或减去datetime64
Index
、Series
或DataFrame
时出现的回归问题 (GH 57529)
Bug 修复#
修复了
pandas.api.interchange.from_dataframe()
对于可空整数引发异常的 Bug (GH 55069)修复了
pandas.api.interchange.from_dataframe()
对于空输入引发异常的 Bug (GH 56700)修复了
pandas.api.interchange.from_dataframe()
未将列名转换为字符串的 Bug (GH 55069)修复了在启用写时复制 (Copy-on-Write) 的情况下,
DataFrame.__getitem__()
对于空DataFrame
的 Bug (GH 57130)修复了
PeriodIndex.asfreq()
中的 Bug,该 Bug 会静默地将不支持作为周期频率的频率进行转换,而不是引发错误 (GH 56945)
其他#
注意
当导入 pandas 但未安装 PyArrow 时引发的 DeprecationWarning
已被移除。做出此决定是因为该警告对许多用户来说过于频繁,并且收到了大量关于将 PyArrow 作为必需依赖项的反馈。Pandas 目前正在考虑是否在 3.0 版本中将 PyArrow 添加为硬依赖项。感兴趣的用户可以在此处关注讨论。
贡献者#
共有 14 位贡献者为本次发布提交了补丁。名字旁边有“+”的人是首次贡献补丁。
Albert Villanova del Moral
Luke Manley
Lumberbot (aka Jack)
Marco Edward Gorelli
Matthew Roeschke
Natalia Mokeeva
Pandas Development Team
Patrick Hoefler
Richard Shadrach
Robert Schmidtke +
Samuel Chai +
Thomas Li
William Ayd
dependabot[bot]