2.2.1 版(2024 年 2 月 22 日)更新内容#
以下是 pandas 2.2.1 中的更改。有关包括其他 pandas 版本在内的完整更新日志,请参阅发布说明。
改进#
添加了
pyarrowpip 额外依赖项,因此用户可以使用pip install pandas[pyarrow]来安装 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()在其他值包含非 NaN 的空值时引发KeyError的回归 (GH 57318)修复了
DataFrame.groupby()在某些情况下按Series分组时引发ValueError的回归 (GH 57276)修复了
DataFrame.loc()对于非唯一、带掩码 dtype 索引且结果行数超过 10,000 行时引发IndexError的回归 (GH 57027)修复了
DataFrame.loc()在使用部分行索引器和多列进行扩展时,不必要地抛出“不兼容 dtype 警告”的回归(参见 PDEP6)(GH 56503)修复了
DataFrame.map()中na_action="ignore"对 NumPy 可空类型和ArrowDtypes未生效的回归 (GH 57316)修复了
DataFrame.merge()对某些第三方扩展数组类型引发ValueError的回归 (GH 57316)修复了
DataFrame.query()在所有列均为对象 dtype 的NaT时引发的回归 (GH 57068)修复了
DataFrame.shift()在axis=1和空DataFrame时引发AssertionError的回归 (GH 57301)修复了
DataFrame.sort_index()对含有重复值的索引未生成稳定排序的回归 (GH 57151)修复了
DataFrame.to_dict()在使用orient='list'且日期时间或时间差类型返回整数的回归 (GH 54824)修复了
DataFrame.to_json()将可空整数转换为浮点数的回归 (GH 57224)修复了
DataFrame.to_sql()在传递method="multi"且方言类型不是 Oracle 时引发的回归 (GH 57310)修复了
DataFrame.transpose()在使用可空扩展 dtype 且数据非 F-连续时可能导致异常的回归 (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 指定为浮点型且数据包含 NaNs 时引发的回归 (GH 57121)修复了带毫秒分量的
DateOffset对象与datetime64Index、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的DataFrame.__getitem__()中的 bug (GH 57130)修复了
PeriodIndex.asfreq()默默地转换不支持作为周期频率的频率,而不是引发错误的 bug (GH 56945)
其他#
注意
当未安装 PyArrow 而导入 pandas 时引发的 DeprecationWarning 已被移除。做出此决定是因为该警告对许多用户来说过于嘈杂,并且收集了大量关于将 PyArrow 作为必需依赖项的决定的反馈。Pandas 目前正在考虑是否应在 3.0 版本中将 PyArrow 添加为硬依赖项的决定。感兴趣的用户可以在此处关注讨论。
贡献者#
共有 14 人为本次发布贡献了补丁。名字旁边带有“+”的人是首次贡献补丁。
Albert Villanova del Moral
Luke Manley
Lumberbot (又名 Jack)
Marco Edward Gorelli
Matthew Roeschke
Natalia Mokeeva
Pandas 开发团队
Patrick Hoefler
Richard Shadrach
Robert Schmidtke +
Samuel Chai +
Thomas Li
William Ayd
dependabot[bot]