Pandas-2-2-中文文档-四十一-

Pandas 2.2 中文文档(四十一)

原文:pandas.pydata.org/docs/

2.1.4 新特性(2023 年 12 月 8 日)

原文:pandas.pydata.org/docs/whatsnew/v2.1.4.html

这些是 pandas 2.1.4 中的更改。请参阅发行说明以获取包括 pandas 的其他版本在内的完整更改日志。

回归修复

  • 修复了从 pandas 1.3 读取一个被 pickled 的 pandas DataFrame 时的回归错误 (GH 55137) ## Bug 修复

  • indexSeries 列表时,Series 构造函数引发 DeprecationWarning 的错误 (GH 55228)

  • 当尝试将日期类似的字符串输入转换为 ArrowDtypepyarrow.timestamp 时,Series 中的错误 (GH 56266)

  • 使用 ts_input="now"ts_input="today" 构建 Timestamp 时,与 Timestamp.now()Timestamp.today() 给出的单位不同的错误 (GH 55879)

  • Index.__getitem__() 中的错误,对于 Arrow 数据类型和负步长返回错误的结果(GH 55832

  • infer_string 选项设置时,修复了 read_csv() 中不尊重对象数据类型的错误 (GH 56047)

  • 修复了 to_numeric() 中的错误,将 string[pyarrow_numpy] 数据类型转换为扩展数据类型 (GH 56179)

  • 修复了 DataFrameGroupBy.min()DataFrameGroupBy.max() 中不保留空对象的扩展数据类型的错误 (GH 55619)

  • infer_string 选项设置时,修复了 DataFrame.__setitem__() 中将带有对象数据类型的 Index 转换为 PyArrow 后端字符串的错误 (GH 55638)

  • 修复了 DataFrame.to_hdf() 中的错误,当列具有 StringDtype 时引发异常 (GH 55088)

  • 修复了 Index.insert() 中的错误,在设置 infer_string 选项时将对象数据类型转换为 PyArrow 支持的字符串 (GH 55638)

  • 修复了 Series.__ne__() 中的错误,导致 dtype="string[pyarrow_numpy]"NA 与字符串值的比较结果为 False (GH 56122)

  • 修复了 Series.mode() 中的错误,当设置 infer_string 时未保留对象数据类型 (GH 56183)

  • 修复了 Series.reset_index() 中的错误,当设置 infer_string 时未保留对象数据类型 (GH 56160)

  • 修复了 Series.str.split()Series.str.rsplit() 中的错误,当 pat=None 时对带有 pyarrow.stringArrowDtype (GH 56271)

  • 修复了 Series.str.translate() 中的错误,在设置字符串选项时丢失对象数据类型 (GH 56152) ## 贡献者

本次发布共有 12 人贡献了补丁。名字后带有“+”符号的人是首次贡献补丁的。

  • Daniel Isaac

  • Joris Van den Bossche

  • Luke Manley

  • Lumberbot(又名 Jack)

  • Marco Edward Gorelli

  • Matthew Roeschke

  • Pandas 开发团队

  • Patrick Hoefler

  • Thomas Li

  • William Ayd

  • Yao Xiao

  • pre-commit-ci[bot] ## 修复的回归

  • 修复了从 pandas 1.3 读取序列化的 pandas DataFrame 时出现的回归错误 (GH 55137)

Bug 修复

  • Series 构造函数中修复了当 indexSeries 列表时引发 DeprecationWarning 的错误 (GH 55228)

  • 当尝试将日期类似的字符串输入转换为pyarrow.timestampArrowDtype时,Series中的 bug(GH 56266)

  • 使用ts_input="now"ts_input="today"构造Timestamp时的 bug,与Timestamp.now()Timestamp.today()给出的单位不同(GH 55879)

  • Index.__getitem__()中的 bug 返回了 Arrow dtypes 和负步长的错误结果(GH 55832)

  • 修复了read_csv()中的 bug,在设置infer_string选项时未尊重对象 dtype(GH 56047)

  • 修复了to_numeric()中的 bug,将string[pyarrow_numpy] dtype 转换为扩展 dtype(GH 56179)

  • 修复了DataFrameGroupBy.min()DataFrameGroupBy.max()在空对象时未保留扩展 dtype 的 bug(GH 55619)

  • 修复了DataFrame.__setitem__()中的 bug,在设置infer_string选项时将具有对象 dtype 的Index转换为 PyArrow 支持的字符串(GH 55638)

  • 修复了DataFrame.to_hdf()中的 bug,在列具有StringDtype时引发错误(GH 55088)

  • 修复了Index.insert()中的 bug,在设置infer_string选项时将对象 dtype 转换为 PyArrow 支持的字符串(GH 55638)

  • Series.__ne__()中的 bug 修复,导致dtype="string[pyarrow_numpy]"NA与字符串值比较时结果为 False(GH 56122)

  • 修复了Series.mode()在设置infer_string时未保持对象数据类型的错误(GH 56183

  • 修复了Series.reset_index()在设置infer_string时未保留对象数据类型的错误(GH 56160

  • 修复了Series.str.split()Series.str.rsplit()在对带有pyarrow.stringArrowDtype使用pat=None时的错误(GH 56271

  • 修复了Series.str.translate()在设置字符串选项时丢失对象数据类型的错误(GH 56152

贡献者

共有 12 人为此版本提供了补丁。带有“+”标记的人第一次贡献了补丁。

  • 丹尼尔·艾萨克

  • 乔里斯·范丹·博斯

  • 卢克·曼利

  • 伐木机器人(又名杰克)

  • 马尔科·爱德华·戈雷利

  • 马修·罗斯克

  • Pandas 开发团队

  • 帕特里克·霍夫勒

  • 托马斯·李

  • 威廉·艾德

  • 姚晓

  • pre-commit-ci[bot]

2.1.3 版本新功能(2023 年 11 月 10 日)

原文:pandas.pydata.org/docs/whatsnew/v2.1.3.html

这些是 pandas 2.1.3 版本的变化。请参阅发布说明以获取包括其他版本在内的完整更改日志。

修复的回归问题

  • 修复了某些 DataFrame 子类上返回新对象的操作导致的无限递归(GH 55763) ## Bug 修复

  • 修复了 DatetimeIndex.diff() 引发 TypeError 的错误(GH 55080

  • 修复了 Index.isin() 在 Arrow 支持的字符串和 None 值时引发的错误(GH 55821

  • 修复了 read_parquet()read_feather() 中的 CVE-2023-47248GH 55894) ## 贡献者

总共有 11 人为这个版本贡献了补丁。名字后面带有“+”的人是首次贡献补丁的。

  • 艾萨克·维尔舒普

  • 乔里斯·范登博斯

  • 卢克·曼利

  • 木材机器人(又名杰克)

  • Marco Edward Gorelli

  • MarcoGorelli

  • 马修·罗斯克

  • Pandas 开发团队

  • 托马斯·李

  • 威廉·艾德

  • 钴 + ## 修复的回归问题

  • 修复了某些 DataFrame 子类上返回新对象的操作导致的无限递归(GH 55763

Bug 修复

  • 修复了 DatetimeIndex.diff() 引发 TypeError 的错误(GH 55080

  • 修复了 Index.isin() 在 Arrow 支持的字符串和 None 值时引发的错误(GH 55821

  • 修复了 read_parquet()read_feather() 中的 CVE-2023-47248GH 55894

贡献者

总共有 11 人为这个版本贡献了补丁。名字后面带有“+”的人是首次贡献补丁的。

  • 艾萨克·维尔舒普

  • 乔里斯·范登博斯

  • 卢克·曼利

  • 木材机器人(又名杰克)

  • Marco Edward Gorelli

  • MarcoGorelli

  • 马修·罗斯克

  • Pandas 开发团队

  • 托马斯·李

  • 威廉·艾德

  • 钴 +

2.1.2 版本的新功能(2023 年 10 月 26 日)

原文:pandas.pydata.org/docs/whatsnew/v2.1.2.html

这些是 pandas 2.1.2 中的更改。查看发布说明以获取包括其他版本的 pandas 在内的完整更改日志。

弃用

  • 撤销了在DataFrame.pct_change()Series.pct_change()DataFrameGroupBy.pct_change()SeriesGroupBy.pct_change()fill_method=None的弃用;值'backfill''bfill''pad''ffill'仍然被弃用(GH 53491) ## 修复的回归问题

  • 修复了DataFrame.join()中的回归问题,结果缺少值且 dtype 为 arrow backed string 时(GH 55348)

  • 修复了rolling()中的回归问题,其中非纳秒索引或on列会产生不正确的结果(GH 55026, GH 55106, GH 55299)

  • 修复了DataFrame.resample()中的回归问题,当origin超出其边界时,会向后外推到originGH 55064)

  • 修复了DataFrame.sort_index()中的回归问题,当索引是切片的MultiIndex时,排序不正确(GH 55379)

  • 修复了DataFrameGroupBy.agg()SeriesGroupBy.agg()中的回归问题,��果选项compute.use_numba设置为 True,则不受 numba 引擎支持的 groupby 方法会引发TypeErrorGH 55520)

  • 修复了宽 DataFrame 的性能回归问题,通常涉及访问所有列的方法时,会单独访问每一列(GH 55256, GH 55245)

  • 修复了merge_asof()中的回归问题,对于具有日期时间和时间间隔数据类型的by引发TypeErrorGH 55453)

  • 修复了read_parquet() 在读取包含超过 2 GB 字符串数据的字符串列文件并使用 "string" 数据类型时的回归错误 (GH 55606)

  • 修复了在使用 detect_types 时,DataFrame.to_sql() 在 sqlite 中未正确往返 datetime 列的回归错误 (GH 55554)

  • 修复了某些 DataFrame 或 Series 子类构造中的回归错误 (GH 54922) ## Bug 修复

  • 修复了当设置 infer_stringDataFrameGroupBy 缩减未保留对象数据类型的错误 (GH 55620)

  • 修复了SeriesGroupBy.value_counts() 在返回字符串列时返回错误的数据类型的错误(GH 55627)

  • 修复了如果其他对象具有箭头支持的字符串数据类型,则 Categorical.equals() 的错误 (GH 55364)

  • 修复了 DataFrame.__setitem__() 在使用 infer_string=True 时不会为零维数组推断字符串数据类型的错误 (GH 55366)

  • 修复了 DataFrame.idxmin()DataFrame.idxmax() 在箭头数据类型时引发的错误 (GH 55368)

  • 修复了 DataFrame.interpolate() 引发不正确错误消息的错误 (GH 55347)

  • 修复了 Index.insert() 在将 None 插入具有 dtype="string[pyarrow_numpy]"Index 时引发的错误 (GH 55365)

  • 修复了 Series.all()Series.any()dtype="string[pyarrow_numpy]" 时未正确处理缺失值的错误 (GH 55367)

  • 修复了Series.floordiv()中的错误,针对ArrowDtypeGH 55561)

  • 修复了Series.mode()中 arrow 支持的字符串 dtype 未排序值的错误(GH 55621)

  • 修复了Series.rank()string[pyarrow_numpy] dtype 的错误(GH 55362)

  • 修复了Series.str.extractall()中的错误,因为ArrowDtype dtype 被转换为 object(GH 53846)

  • 修复了创建新条件列时显示 PDEP-6 警告(关于设置不兼容 dtype��项)的错误(GH 55025)

  • 在正常绘图活动中消除了由GH 53446引入的Period[B]警告(GH 55138)

  • 修复了Series构造函数在NA是第一个值且infer_string被设置时未推断出字符串 dtype 的错误(:issue: 55655) ## 其他

  • 修复了可选依赖组output_formatting的安装失败。用破折号-替换下划线_可以修复依赖关系解析失败的问题。现在正确的使用方式是pip install pandas[output-formatting]。 ## 贡献者

总共有 20 人为这个版本贡献了补丁。名字后面带有“+”的人是第一次贡献补丁。

  • Amanda Bizzinotto

  • Artur Barseghyan +

  • Hadi Abdi Khojasteh +

  • Joris Van den Bossche

  • Luke Manley

  • Lumberbot(又名 Jack)

  • Marc Garcia

  • Marco Edward Gorelli

  • MarcoGorelli

  • Mateusz Sokół

  • Matthew Roeschke

  • Natalia Mokeeva

  • Pandas 开发团队

  • Patrick Hoefler

  • Richard Shadrach

  • Thomas Li

  • Yao Xiao

  • dependabot[bot]

  • rohanjain101 +

  • torext + ## 弃用

  • 撤销了在DataFrame.pct_change()Series.pct_change()DataFrameGroupBy.pct_change()SeriesGroupBy.pct_change()fill_method=None的弃用;值'backfill''bfill''pad''ffill'仍然被弃用(GH 53491)

修复的回归

  • 修复了DataFrame.join()中的回归问题,其中结果具有缺失值且 dtype 是 arrow 支持的字符串类型(GH 55348

  • 修复了rolling()中的回归问题,其中非纳秒索引或on列会产生不正确的结果(GH 55026GH 55106GH 55299

  • 修复了DataFrame.resample()中的回归问题,当origin超出其界限时会向后外推originGH 55064

  • 修复了DataFrame.sort_index()中的回归问题,在索引为切片的情况下未正确排序MultiIndexGH 55379

  • 修复了DataFrameGroupBy.agg()SeriesGroupBy.agg()中的回归问题,当选项compute.use_numba设置为 True 时,不受 numba 引擎支持的 groupby 方法会引发TypeErrorGH 55520

  • 修复了宽 DataFrame 的性能回归问题,通常涉及访问所有列的方法(GH 55256GH 55245

  • 修复了在merge_asof()中的回归问题,对于具有日期时间和时间间隔 dtype 的by会引发TypeErrorGH 55453

  • 修复了在使用"string"dtype 时读取具有超过 2 GB 字符串数据的文件时的read_parquet()中的回归问题(GH 55606

  • 修复了DataFrame.to_sql()中的回归问题,在使用detect_types时,sqlite 的 datetime 列未正确回环(GH 55554

  • 修复了某些 DataFrame 或 Series 子类构造中的回归问题(GH 54922

Bug 修复

  • 修复了DataFrameGroupBy规约时当infer_string设置时未保留对象 dtype 的回归问题(GH 55620

  • 修复了SeriesGroupBy.value_counts()中的错误,为字符串列返回了不正确的数据类型(GH 55627)

  • 修复了Categorical.equals()中的错误,如果其他数据具���arrow 支持的字符串数据类型(GH 55364)

  • 修复了DataFrame.__setitem__()中的错误,对于使用infer_string=True的零维数组未推断出字符串数据类型(GH 55366)

  • 修复了DataFrame.idxmin()DataFrame.idxmax()中的错误,对于 arrow 数据类型引发异常(GH 55368)

  • 修复了DataFrame.interpolate()中的错误,引发了不正确的错误消息(GH 55347)

  • 修复了Index.insert()中的错误,当将None插入到带有dtype="string[pyarrow_numpy]"Index时引发异常(GH 55365)

  • 修复了Series.all()Series.any()中的错误,对于dtype="string[pyarrow_numpy]"未正确处理缺失值(GH 55367)

  • 修复了Series.floordiv()中的错误,适用于ArrowDtypeGH 55561)

  • 修复了Series.mode()中的错误,对于 arrow 支持的字符串数据类型未对值进行排序(GH 55621)

  • 修复了Series.rank()中的错误,适用于string[pyarrow_numpy]数据类型(GH 55362)

  • 修复了Series.str.extractall()中的错误,适用于被转换为对象的ArrowDtype数据类型(GH 53846)

  • 修复了创建新的条件列时出现 PDEP-6 警告的 bug,该警告是关于设置不兼容 dtype 的项时显示的(GH 55025

  • 在正常绘图活动中消除了由 GH 53446 引入的Period[B]警告(GH 55138

  • 修复了Series构造函数在NA是第一个值且infer_string被设置时没有推断出字符串 dtype 的 bug(:issue: 55655

其他

  • 修复了可选依赖组output_formatting安装失败的问题。将下划线_替换为破折号-可以修复依赖解析错误的问题。现在的正确用法是pip install pandas[output-formatting]

贡献者

共有 20 人为此版本提交了补丁。名字后面带有“+”符号的人第一次贡献了补丁。

  • Amanda Bizzinotto

  • Artur Barseghyan +

  • Hadi Abdi Khojasteh +

  • Joris Van den Bossche

  • Luke Manley

  • 木材机器人(又名 Jack)

  • Marc Garcia

  • Marco Edward Gorelli

  • MarcoGorelli

  • Mateusz Sokół

  • Matthew Roeschke

  • Natalia Mokeeva

  • Pandas 开发团队

  • Patrick Hoefler

  • Richard Shadrach

  • Thomas Li

  • Yao Xiao

  • dependabot[bot]

  • rohanjain101 +

  • torext +

2.1.1 版中的新功能(2023 年 9 月 20 日)

原文:pandas.pydata.org/docs/whatsnew/v2.1.1.html

这些是 pandas 2.1.1 版中的更改。详见发布说明以获取包括其他版本的完整更改日志。

修复的回归问题

  • 修复了 concat()DataFrame 具有两种不同扩展 dtype 时的回归问题 (GH 54848)

  • 修复了 merge() 在合并 PyArrow 字符串索引时的回归问题 (GH 54894)

  • 修复了 read_csv() 在给定 usecolsdtypesengine="python" 的字典时的回归问题 (GH 54868)

  • 修复了 read_csv()delim_whitespace 为 True 时的回归问题(GH 54918, GH 54931

  • 修复了 GroupBy.get_group()axis=1 时引发的回归问题 (GH 54858)

  • 修复了 DataFrame.__setitem__() 在设置带有部分 MultiIndexSeries 时引发 AssertionError 的回归问题 (GH 54875)

  • 修复了 DataFrame.filter() 不遵守 filter 元素顺序的回归问题 (GH 54980)

  • 修复了 DataFrame.to_sql() 在 sqlite 中未正确往返 datetime 列的回归问题 (GH 54877)

  • 修复了 DataFrameGroupBy.agg() 在使用字典聚合具有重复列名的 DataFrame 时的回归问题 (GH 55006)

  • 修复了 MultiIndex.append() 在附加重叠的 IntervalIndex 级别时引发的回归问题 (GH 54934)

  • 修复了Series.drop_duplicates()在 PyArrow 字符串中的回归问题(GH 54904)

  • 修复了Series.interpolate()在给定fill_value时引发的回归问题(GH 54920)

  • 修复了Series.value_counts()在指定bins时对数值数据引发的回归问题(GH 54857)

  • 修复了 PyArrow 支持的列的比较操作中未正确传播异常的回归问题(GH 54944)

  • 修复了将具有datetime64 dtype 的SeriesNone进行比较时的回归问题(GH 54870) ## Bug 修复

  • 修复了ArrowDtype在固定大小列表中引发NotImplementedError的错误(GH 55000)

  • 修复了带有future_stack=True和由元组组成的非MultiIndex列的DataFrame.stack()中的错误(GH 54948)

  • 修复了Series.dt.tz()在具有ArrowDtype的情况下返回字符串而不是tzinfo对象的错误(GH 55003)

  • 修复了Series.pct_change()DataFrame.pct_change()显示不必要的FutureWarning的错误(GH 54981) ## 其他

  • 撤销了不允许Series.apply()在传入的可调用函数返回Series对象时返回DataFrame的弃用(GH 52116) ## 贡献者

本次发布共有 13 人贡献了补丁。带有“+”标记的人是第一次贡献补丁的。

  • Ben Greiner +

  • Joris Van den Bossche

  • Kai Mühlbauer +

  • Luke Manley

  • Lumberbot(又名 Jack)

  • Mateusz Sokół

  • Matthew Roeschke

  • Pandas 开发团队

  • Patrick Hoefler

  • Rajat Subhra Mukherjee

  • Ralf Gommers

  • Richard Shadrach

  • Thomas Li ## 修复的回归问题

  • DataFrame具有两种不同的扩展 dtype 时,在concat()中修复了回归问题(GH 54848

  • merge()中修复了 PyArrow 字符串索引合并时的回归问题(GH 54894

  • usecols给定且dtypesengine="python"的字典时,在read_csv()中修复了回归问题(GH 54868

  • delim_whitespace为 True 时,在read_csv()中修复了回归问题(GH 54918, GH 54931

  • axis=1时,修复了GroupBy.get_group()引发的回归问题(GH 54858

  • 在设置带有部分MultiIndexSeries时,修复了DataFrame.__setitem__()引发AssertionError的回归问题(GH 54875

  • filter时,修复了DataFrame.filter()不遵守元素顺序的回归问题(GH 54980

  • 在 sqlite 中正确地回路 datetime 列时,在DataFrame.to_sql()中修复了回归问题(GH 54877

  • 在使用字典时,通过字典聚合具有重复列名的 DataFrame 时,修复了DataFrameGroupBy.agg()引发的回归问题(GH 55006

  • 在追加重叠的IntervalIndex级别时,修复了MultiIndex.append()引发的回归问题(GH 54934

  • 修复了 PyArrow 字符串在Series.drop_duplicates()中的回归问题(GH 54904)

  • 修复了在指定fill_valueSeries.interpolate()引发错误的回归问题(GH 54920)

  • 修复了Series.value_counts()在指定bins时对数值数据引发错误的回归问题(GH 54857)

  • 修复了 PyArrow 支持的列在比较操作中出现回归问题,未正确传播异常(GH 54944)

  • 在将Seriesdatetime64 dtype 与None进行比较时出现回归问题的修复(GH 54870)

Bug 修复

  • 修复了ArrowDtype在固定大小列表中引发NotImplementedError的错误(GH 55000)

  • 修复了使用future_stack=True和列为元组的非MultiIndexDataFrame.stack()的错误(GH 54948)

  • 修复了在使用ArrowDtypeSeries.dt.tz()中返回字符串而不是tzinfo对象的错误(GH 55003)

  • 修复了Series.pct_change()DataFrame.pct_change()中显示不必要的FutureWarning的错误(GH 54981)

其他

  • 撤销了不允许Series.apply()在传入的可调用对象返回Series对象时返回DataFrame的弃用功能(GH 52116)

贡献者

总共有 13 人为这个版本贡献了补丁。名字后面带有“+”符号的人是第一次贡献补丁。

  • Ben Greiner +

  • Joris Van den Bossche

  • Kai Mühlbauer +

  • Luke Manley

  • Lumberbot(又名杰克)

  • Mateusz Sokół

  • Matthew Roeschke

  • Pandas 开发团队

  • Patrick Hoefler

  • Rajat Subhra Mukherjee

  • Ralf Gommers

  • Richard Shadrach

  • Thomas Li

2.1.0 中的新功能(2023 年 8 月 30 日)

原文:pandas.pydata.org/docs/whatsnew/v2.1.0.html

这些是 pandas 2.1.0 中的更改。查看发布说明以获取包括其他版本的 pandas 在内的完整更改日志。

增强功能

PyArrow 将成为 pandas 3.0 的必需依赖项

PyArrow 将从 pandas 3.0 开始成为 pandas 的必需依赖项。这个决定是基于 PDEP 10做出的。

这将使更多对 pandas 用户极其有益的更改成为可能,包括但不限于:

  • 默认情况下推断字符串为 PyArrow 支持的字符串,可以显著减少内存占用并获得巨大的性能改进。

  • 默认情况下使用 PyArrow 推断更复杂的 dtypes,如 Decimallistsbytesstructured data 等。

  • 与依赖于 Apache Arrow 的其他库更好地互操作。

我们正在收集有关此决定的反馈 此处。### 默认情况下避免使用 NumPy 对象 dtype 存储字符串

以前,默认情况下,所有字符串都存储在具有 NumPy 对象 dtype 的列中。此版本引入了一个选项 future.infer_string,将所有字符串推断为 PyArrow 支持的字符串,dtype 为 "string[pyarrow_numpy]"。这是一种新的字符串 dtype 实现,遵循 NumPy 在比较操作中的语义,并将 np.nan 作为缺失值指示符。设置该选项还将推断 dtype "string"StringDtype,存储设置为 "pyarrow_numpy",忽略选项 mode.string_storage 后面的值。

该选项仅在安装了 PyArrow 时才有效。与 NumPy 对象相比,PyArrow 支持的字符串具有显著减少的内存占用,并为用户提供了大幅度的性能改进(GH 54430)。

可以通过以下方式启用该选项:

pd.options.future.infer_string = True 

这种行为将在 pandas 3.0 中成为默认行为。### DataFrame reductions preserve extension dtypes

在之前的 pandas 版本中,DataFrame reductions(DataFrame.sum() DataFrame.mean() 等)的结果具有 NumPy dtypes,即使 DataFrame 是扩展 dtypes。现在,Pandas 可以在对具有共同 dtype 的 DataFrame 列进行减少时保留 dtypes(GH 52788)。

旧行为

In [1]: df = pd.DataFrame({"a": [1, 1, 2, 1], "b": [np.nan, 2.0, 3.0, 4.0]}, dtype="Int64")
In [2]: df.sum()
Out[2]:
a    5
b    9
dtype: int64
In [3]: df = df.astype("int64[pyarrow]")
In [4]: df.sum()
Out[4]:
a    5
b    9
dtype: int64 

新行为

In [1]: df = pd.DataFrame({"a": [1, 1, 2, 1], "b": [np.nan, 2.0, 3.0, 4.0]}, dtype="Int64")

In [2]: df.sum()
Out[2]: 
a    5
b    9
dtype: Int64

In [3]: df = df.astype("int64[pyarrow]")

In [4]: df.sum()
Out[4]: 
a    5
b    9
dtype: int64[pyarrow] 

请注意,dtype 现在分别是掩码 dtype 和 PyArrow dtype,而以前是 NumPy 整数 dtype。

为了允许 DataFrame 缩减保留扩展 dtypes,ExtensionArray._reduce() 增加了一个新的关键字参数 keepdims。调用 ExtensionArray._reduce() 时,keepdims=True 应该沿着缩减轴返回长度为 1 的数组。为了保持向后兼容性,该参数不是必需的,但将来可能会变为必需。如果在签名中找不到该参数,则 DataFrame 缩减将无法保留扩展 dtypes。此外,如果找不到该参数,将会发出 FutureWarning,并且像 mypy 这样的类型检查器可能会抱怨签名与 ExtensionArray._reduce() 不兼容。 ### 写时复制改进

  • func 修改 Series 时,Series.transform() 不尊重写时复制 (GH 53747)

  • 调用 Index.values() 现在将返回一个只读的 NumPy 数组 (GH 53704)

  • Series 设置到 DataFrame 中现在会创建一个惰性副本而不是深度副本 (GH 53142)

  • 当从 Index 对象字典构造 DataFrame 并指定 copy=False 时,DataFrame 构造函数现在将使用这些 Index 对象的惰性副本作为 DataFrame 的列 (GH 52947)

  • 对于 Series 或 DataFrame 的浅复制 (df.copy(deep=False)) 现在也会返回行/列 Index 对象的浅复制,而不仅仅是数据的浅复制,即结果的索引不再相同 (df.copy(deep=False).index is df.index 不再为 True) (GH 53721)

  • DataFrame.head()DataFrame.tail() 现在将返回深拷贝(GH 54011

  • DataFrame.eval()添加延迟复制机制(GH 53746

  • 当尝试在临时列选择上进行就地操作时(例如,df["a"].fillna(100, inplace=True)),当启用写时复制时,将始终发出警告。在这种模式下,像这样就地操作永远不起作用,因为该选择行为类似于临时副本。这对以下操作也适用:

    • DataFrame.update / Series.update

    • DataFrame.fillna / Series.fillna

    • DataFrame.replace / Series.replace

    • DataFrame.clip / Series.clip

    • DataFrame.where / Series.where

    • DataFrame.mask / Series.mask

    • DataFrame.interpolate / Series.interpolate

    • DataFrame.ffill / Series.ffill

    • DataFrame.bfill / Series.bfill ### 新 DataFrame.map() 方法和对 ExtensionArrays 的支持

DataFrame.map() 方法已添加,DataFrame.applymap() 已被弃用。DataFrame.map() 具有与 DataFrame.applymap() 相同的功能,但新名称更好地传达了这是 DataFrame 版本的 Series.map() (GH 52353).

给定一个可调用对象时,Series.map() 将该可调用对象应用于Series 的所有元素。类似地,DataFrame.map() 将该可调用对象应用于DataFrame 的所有元素,而 Index.map() 将该可调用对象应用于Index 的所有元素。

经常情况下,不希望将可调用对象应用于数组的类似 nan 的值,并且为了避免这样做,可以使用na_action="ignore"调用map方法,即ser.map(func, na_action="ignore")。但是,na_action="ignore"没有为许多ExtensionArrayIndex类型实现,并且除了可空数值类型(即 dtype 为Int64等)之外,na_action="ignore"对任何ExtensionArray子类都不起作用。

na_action="ignore"现在适用于所有数组类型(GH 52219GH 51645GH 51809GH 51936GH 52033GH 52096)。

先前的行为

In [1]: ser = pd.Series(["a", "b", np.nan], dtype="category")
In [2]: ser.map(str.upper, na_action="ignore")
NotImplementedError
In [3]: df = pd.DataFrame(ser)
In [4]: df.applymap(str.upper, na_action="ignore")  # worked for DataFrame
 0
0    A
1    B
2  NaN
In [5]: idx = pd.Index(ser)
In [6]: idx.map(str.upper, na_action="ignore")
TypeError: CategoricalIndex.map() got an unexpected keyword argument 'na_action' 

新行为

In [5]: ser = pd.Series(["a", "b", np.nan], dtype="category")

In [6]: ser.map(str.upper, na_action="ignore")
Out[6]: 
0      A
1      B
2    NaN
dtype: category
Categories (2, object): ['A', 'B']

In [7]: df = pd.DataFrame(ser)

In [8]: df.map(str.upper, na_action="ignore")
Out[8]: 
 0
0    A
1    B
2  NaN

In [9]: idx = pd.Index(ser)

In [10]: idx.map(str.upper, na_action="ignore")
Out[10]: CategoricalIndex(['A', 'B', nan], categories=['A', 'B'], ordered=False, dtype='category') 

另外,请注意,Categorical.map()na_action隐式地默认设置为"ignore"。这已经被弃用,Categorical.map()的默认值将更改为na_action=None,与所有其他数组类型一致。### DataFrame.stack()的新实现

pandas 已重新实现了DataFrame.stack()。要使用新实现,请传递参数future_stack=True。这将成为 pandas 3.0 中唯一的选项。

先前的实现有两个主要的行为缺点。

  1. 先前的实现会不必要地在结果中引入 NA 值。用户可以通过传递dropna=True(默认值)来自动删除 NA 值,但这样做也可能会从结果中删除存在于输入中的 NA 值。请参见下面的示例。

  2. 先前的实现中带有sort=True(默认值)的情况下,有时会对结果索引的一部分进行排序,有时不会。如果输入的列不是MultiIndex,则结果索引永远不会被排序。如果列是MultiIndex,则在大多数情况下,来自堆叠列级别的结果索引的级别将被排序。在某些罕见的情况下,这些级别将按非标准顺序排序,具体取决于如何创建列。

新的实现(future_stack=True)在堆叠多个级别时不再无必要地引入 NA 值,并且永远不会排序。因此,在使用 future_stack=True 时,参数 dropnasort 不会被使用,必须保持未指定。这些参数将在下一个主要版本中被删除。

In [11]: columns = pd.MultiIndex.from_tuples([("B", "d"), ("A", "c")])

In [12]: df = pd.DataFrame([[0, 2], [1, 3]], index=["z", "y"], columns=columns)

In [13]: df
Out[13]: 
 B  A
 d  c
z  0  2
y  1  3 

在上一个版本中(future_stack=False),dropna=True 的默认值会删除无必要引入的 NA 值,但在此过程中仍会强制转换 dtype 为 float64。在新版本中,不会引入 NA,并且因此不会强制转换 dtype。

In [14]: df.stack([0, 1], future_stack=False, dropna=True)
Out[14]: 
z  A  c    2.0
 B  d    0.0
y  A  c    3.0
 B  d    1.0
dtype: float64

In [15]: df.stack([0, 1], future_stack=True)
Out[15]: 
z  B  d    0
 A  c    2
y  B  d    1
 A  c    3
dtype: int64 

如果输入包含 NA 值,上一个版本将使用 dropna=True 删除这些值,或者使用 dropna=False 引入新的 NA 值。新版本将保留输入中的所有值。

In [16]: df = pd.DataFrame([[0, 2], [np.nan, np.nan]], columns=columns)

In [17]: df
Out[17]: 
 B    A
 d    c
0  0.0  2.0
1  NaN  NaN

In [18]: df.stack([0, 1], future_stack=False, dropna=True)
Out[18]: 
0  A  c    2.0
 B  d    0.0
dtype: float64

In [19]: df.stack([0, 1], future_stack=False, dropna=False)
Out[19]: 
0  A  d    NaN
 c    2.0
 B  d    0.0
 c    NaN
1  A  d    NaN
 c    NaN
 B  d    NaN
 c    NaN
dtype: float64

In [20]: df.stack([0, 1], future_stack=True)
Out[20]: 
0  B  d    0.0
 A  c    2.0
1  B  d    NaN
 A  c    NaN
dtype: float64 
```  ### 其他增强

+   `Series.ffill()` 和 `Series.bfill()` 现在支持具有 `IntervalDtype` 的对象([GH 54247](https://github.com/pandas-dev/pandas/issues/54247))

+   添加了 `filters` 参数到 `read_parquet()` 以过滤数据,兼容 `engines`([GH 53212](https://github.com/pandas-dev/pandas/issues/53212))

+   `Categorical.map()` 和 `CategoricalIndex.map()` 现在有一个 `na_action` 参数。`Categorical.map()` 隐式地对 `na_action` 有一个默认值 `"ignore"`。这已正式被弃用,并将在未来更改为 `None`。还要注意,`Series.map()` 的默认 `na_action=None`,并且对具有分类数据的系列的调用现在将使用 `na_action=None`,除非显式设置为其他值([GH 44279](https://github.com/pandas-dev/pandas/issues/44279))

+   `api.extensions.ExtensionArray` 现在有一个 `map()` 方法([GH 51809](https://github.com/pandas-dev/pandas/issues/51809))

+   `DataFrame.applymap()` 现在使用底层 `api.extensions.ExtensionArray` 实例的 `map()` 方法([GH 52219](https://github.com/pandas-dev/pandas/issues/52219))

+   `MultiIndex.sort_values()` 现在支持 `na_position`([GH 51612](https://github.com/pandas-dev/pandas/issues/51612))

+   `MultiIndex.sortlevel()`和`Index.sortlevel()`获得了一个新关键字`na_position`([GH 51612](https://github.com/pandas-dev/pandas/issues/51612))。

+   `arrays.DatetimeArray.map()`、`arrays.TimedeltaArray.map()`和`arrays.PeriodArray.map()`现在可以接受一个`na_action`参数([GH 51644](https://github.com/pandas-dev/pandas/issues/51644))。

+   `arrays.SparseArray.map()`现在支持`na_action`([GH 52096](https://github.com/pandas-dev/pandas/issues/52096))。

+   当与 URL 一起使用时,`pandas.read_html()`现在支持`storage_options`关键字,允许用户向出站 HTTP 请求添加标头([GH 49944](https://github.com/pandas-dev/pandas/issues/49944))。

+   添加`Index.diff()`和`Index.round()`([GH 19708](https://github.com/pandas-dev/pandas/issues/19708))。

+   将`"latex-math"`添加为`Styler`的`escape`参数的选项,这样在格式化时不会转义`"\("`和`"\)"`之间的所有字符([GH 51903](https://github.com/pandas-dev/pandas/issues/51903))。

+   在`CategoricalDtype`的`repr`信息中添加了类别的 dtype([GH 52179](https://github.com/pandas-dev/pandas/issues/52179))。

+   在`read_excel()`中添加了`engine_kwargs`参数([GH 52214](https://github.com/pandas-dev/pandas/issues/52214))。

+   在新的子模块`pandas.api.typing`中将对类型提示有用的类添加到公共 API 中([GH 48577](https://github.com/pandas-dev/pandas/issues/48577))。

+   实现了`Series.dt.is_month_start`,`Series.dt.is_month_end`,`Series.dt.is_year_start`,`Series.dt.is_year_end`,`Series.dt.is_quarter_start`,`Series.dt.is_quarter_end`,`Series.dt.days_in_month`,`Series.dt.unit`,`Series.dt.normalize`,`Series.dt.day_name()`,`Series.dt.month_name()`,`Series.dt.tz_convert()` 用于 `pyarrow.timestamp` 的 `ArrowDtype` ([GH 52388](https://github.com/pandas-dev/pandas/issues/52388),[GH 51718](https://github.com/pandas-dev/pandas/issues/51718))

+   当索引不是 `MultiIndex` 时,`DataFrameGroupBy.agg()` 和 `DataFrameGroupBy.transform()` 现在支持按多个键分组,用于 `engine="numba"` ([GH 53486](https://github.com/pandas-dev/pandas/issues/53486))

+   `SeriesGroupBy.agg()` 和 `DataFrameGroupBy.agg()` 现在支持将多个函数传递给 `engine="numba"` ([GH 53486](https://github.com/pandas-dev/pandas/issues/53486))

+   `SeriesGroupBy.transform()` 和 `DataFrameGroupBy.transform()` 现在支持将字符串作为 `engine="numba"` 的函数传递([GH 53579](https://github.com/pandas-dev/pandas/issues/53579))

+   `DataFrame.stack()` 添加了 `sort` 关键字,用于指定生成的 `MultiIndex` 是否排序([GH 15105](https://github.com/pandas-dev/pandas/issues/15105))

+   `DataFrame.unstack()` 添加了 `sort` 关键字,用于指定生成的 `MultiIndex` 是否排序([GH 15105](https://github.com/pandas-dev/pandas/issues/15105))

+   `Series.explode()` 现在支持 PyArrow 支持的列表类型([GH 53602](https://github.com/pandas-dev/pandas/issues/53602))

+   `Series.str.join()` 现在支持 `ArrowDtype(pa.string())` ([GH 53646](https://github.com/pandas-dev/pandas/issues/53646))

+   给 `Categorical.from_codes()` 添加了 `validate` 参数([GH 50975](https://github.com/pandas-dev/pandas/issues/50975))

+   添加了 `ExtensionArray.interpolate()`,被 `Series.interpolate()` 和 `DataFrame.interpolate()` 使用([GH 53659](https://github.com/pandas-dev/pandas/issues/53659))

+   向 `DataFrame.to_excel()` 添加了 `engine_kwargs` 参数([GH 53220](https://github.com/pandas-dev/pandas/issues/53220))

+   对 `DatetimeTZDtype` 实现了 `api.interchange.from_dataframe()`([GH 54239](https://github.com/pandas-dev/pandas/issues/54239))

+   在 `DatetimeTZDtype` 上实现了 `__from_arrow__`([GH 52201](https://github.com/pandas-dev/pandas/issues/52201))

+   实现了 `__pandas_priority__`,允许自定义类型优先于 `DataFrame`、`Series`、`Index` 或 `ExtensionArray` 进行算术运算,请参阅开发者指南([GH 48347](https://github.com/pandas-dev/pandas/issues/48347))

+   改进了使用 `DataFrame.merge()` 时出现不兼容列时的错误消息([GH 51861](https://github.com/pandas-dev/pandas/issues/51861))

+   在通过 `DataFrame.isetitem()` 设置具有错误列数的 `DataFrame` 时,改进了错误消息([GH 51701](https://github.com/pandas-dev/pandas/issues/51701))

+   使用不兼容的 `index` 和 `orient` 参数时,改进了 `DataFrame.to_json()` 的错误处理([GH 52143](https://github.com/pandas-dev/pandas/issues/52143))

+   在创建具有空数据(0 行)、没有索引和不正确列数的 DataFrame 时,改进了错误消息([GH 52084](https://github.com/pandas-dev/pandas/issues/52084))

+   在为 `VariableOffsetWindowIndexer` 提供无效的 `index` 或 `offset` 参数时改进了错误消息([GH 54379](https://github.com/pandas-dev/pandas/issues/54379))

+   让 `DataFrame.to_feather()` 接受一个非默认的 `Index` 和非字符串列名 ([GH 51787](https://github.com/pandas-dev/pandas/issues/51787))。

+   向 `Series.apply()` 和 `DataFrame.apply()` 添加了一个新参数`by_row`。当设置为`False`时,提供的可调用函数将始终作用于整个 Series 或 DataFrame ([GH 53400](https://github.com/pandas-dev/pandas/issues/53400), [GH 53601](https://github.com/pandas-dev/pandas/issues/53601))。

+   `DataFrame.shift()` 和 `Series.shift()` 现在允许通过提供一个周期列表进行多周期移位 ([GH 44424](https://github.com/pandas-dev/pandas/issues/44424))。

+   使用 `numba` 的 Groupby 聚合(例如 `DataFrameGroupBy.sum()`)现在可以保留输入的 dtype 而不是强制转换为 `float64` ([GH 44952](https://github.com/pandas-dev/pandas/issues/44952))。

+   当 `DataFrameGroupBy.agg()` 失败时,改进了错误消息 ([GH 52930](https://github.com/pandas-dev/pandas/issues/52930))。

+   许多读取/写入 _* 函数,例如 `DataFrame.to_pickle()` 和 `read_csv()`,支持将压缩参数转发给 `lzma.LZMAFile` ([GH 52979](https://github.com/pandas-dev/pandas/issues/52979))。

+   对于对象 dtype,现在支持缩减`Series.argmax()`、`Series.argmin()`、`Series.idxmax()`、`Series.idxmin()`、`Index.argmax()`、`Index.argmin()`、`DataFrame.idxmax()`、`DataFrame.idxmin()`([GH 4279](https://github.com/pandas-dev/pandas/issues/4279)、[GH 18021](https://github.com/pandas-dev/pandas/issues/18021)、[GH 40685](https://github.com/pandas-dev/pandas/issues/40685)、[GH 43697](https://github.com/pandas-dev/pandas/issues/43697))

+   `DataFrame.to_parquet()`和`read_parquet()`现在分别写入和读取`attrs`([GH 54346](https://github.com/pandas-dev/pandas/issues/54346))

+   与`Series.all()`和`Series.any()`的行为相匹配,浮点 dtype 和 timedelta64 dtype 的`Index.all()`和`Index.any()`不再引发`TypeError`([GH 54566](https://github.com/pandas-dev/pandas/issues/54566))

+   对于 pyarrow 版本 13.0 及以上,现在支持`Series.cummax()`、`Series.cummin()`和`Series.cumprod()`的 pyarrow dtypes([GH 52085](https://github.com/pandas-dev/pandas/issues/52085))

+   已添加对 DataFrame Consortium 标准的支持([GH 54383](https://github.com/pandas-dev/pandas/issues/54383))

+   在 `DataFrameGroupBy.quantile()` 和 `SeriesGroupBy.quantile()` 中提升了性能 ([GH 51722](https://github.com/pandas-dev/pandas/issues/51722))

+   基于 PyArrow 的整数数据类型现在支持位运算 ([GH 54495](https://github.com/pandas-dev/pandas/issues/54495))  ## 不兼容的 API 更改

### 增加了 Python 的最低版本要求

pandas 2.1.0 支持 Python 3.9 及更高版本。

### 增加了依赖项的最低版本要求

一些依赖项的最低支持版本已更新。如果已安装,我们现在要求:

| 包名 | 最低版本 | 必需 | 更改 |
| --- | --- | --- | --- |
| numpy | 1.22.4 | X | X |
| mypy (dev) | 1.4.1 |  | X |
| beautifulsoup4 | 4.11.1 |  | X |
| bottleneck | 1.3.4 |  | X |
| dataframe-api-compat | 0.1.7 |  | X |
| fastparquet | 0.8.1 |  | X |
| fsspec | 2022.05.0 |  | X |
| hypothesis | 6.46.1 |  | X |
| gcsfs | 2022.05.0 |  | X |
| jinja2 | 3.1.2 |  | X |
| lxml | 4.8.0 |  | X |
| numba | 0.55.2 |  | X |
| numexpr | 2.8.0 |  | X |
| openpyxl | 3.0.10 |  | X |
| pandas-gbq | 0.17.5 |  | X |
| psycopg2 | 2.9.3 |  | X |
| pyreadstat | 1.1.5 |  | X |
| pyqt5 | 5.15.6 |  | X |
| pytables | 3.7.0 |  | X |
| pytest | 7.3.2 |  | X |
| python-snappy | 0.6.1 |  | X |
| pyxlsb | 1.0.9 |  | X |
| s3fs | 2022.05.0 |  | X |
| scipy | 1.8.1 |  | X |
| sqlalchemy | 1.4.36 |  | X |
| tabulate | 0.8.10 |  | X |
| xarray | 2022.03.0 |  | X |
| xlsxwriter | 3.0.3 |  | X |
| zstandard | 0.17.0 |  | X |

对于[可选库](https://pandas.pydata.org/docs/getting_started/install.html),一般建议使用最新版本。

查看依赖项和可选依赖项以获取更多信息。

### 其他 API 更改

+   `arrays.PandasArray` 已重命名为 `NumpyExtensionArray`,附加的 dtype 名称从 `PandasDtype` 更改为 `NumpyEADtype`;导入 `PandasArray` 仍然有效,直到下一个主要版本 ([GH 53694](https://github.com/pandas-dev/pandas/issues/53694))  ## 弃用

### 弃用了类似于 setitem 的 Series 操作中的静默类型转换

PDEP-6: [`pandas.pydata.org/pdeps/0006-ban-upcasting.html`](https://pandas.pydata.org/pdeps/0006-ban-upcasting.html)

Series(或 DataFrame 列)上的类似 setitem 的操作,如果静默转换 dtype,则已弃用并显示警告。受影响操作的示例包括:

+   `ser.fillna('foo', inplace=True)`

+   `ser.where(ser.isna(), 'foo', inplace=True)`

+   `ser.iloc[indexer] = 'foo'`

+   `ser.loc[indexer] = 'foo'`

+   `df.iloc[indexer, 0] = 'foo'`

+   `df.loc[indexer, 'a'] = 'foo'`

+   `ser[indexer] = 'foo'`

其中 `ser` 是一个 `Series`,`df` 是一个 `DataFrame`,而 `indexer` 可以是切片、掩码、单个值、值列表或数组,或者其他任何允许的索引器。

在将来的版本中,这些将引发错误,您应首先转换为公共 dtype。

*先前行为*:

```py
In [1]: ser = pd.Series([1, 2, 3])

In [2]: ser
Out[2]:
0    1
1    2
2    3
dtype: int64

In [3]: ser[0] = 'not an int64'

In [4]: ser
Out[4]:
0    not an int64
1               2
2               3
dtype: object 

新行为

In [1]: ser = pd.Series([1, 2, 3])

In [2]: ser
Out[2]:
0    1
1    2
2    3
dtype: int64

In [3]: ser[0] = 'not an int64'
FutureWarning:
 Setting an item of incompatible dtype is deprecated and will raise an error in a future version of pandas.
 Value 'not an int64' has dtype incompatible with int64, please explicitly cast to a compatible dtype first.

In [4]: ser
Out[4]:
0    not an int64
1               2
2               3
dtype: object 

为保留当前行为,在上述情况下,您可以首先将 ser 转换为 object dtype:

In [21]: ser = pd.Series([1, 2, 3])

In [22]: ser = ser.astype('object')

In [23]: ser[0] = 'not an int64'

In [24]: ser
Out[24]: 
0    not an int64
1               2
2               3
dtype: object 

根据使用情况,可能更适合转换为不同的 dtype。例如,在以下情况下,我们转换为 float64

In [25]: ser = pd.Series([1, 2, 3])

In [26]: ser = ser.astype('float64')

In [27]: ser[0] = 1.1

In [28]: ser
Out[28]: 
0    1.1
1    2.0
2    3.0
dtype: float64 

欲了解更多,请参阅 pandas.pydata.org/pdeps/0006-ban-upcasting.html

废弃解析具有混合时区的日期时间

废弃混合时区解析日期时间,并显示警告,除非用户将 utc=True 传递给 to_datetime()GH 50887

先前行为

In [7]: data = ["2020-01-01 00:00:00+06:00", "2020-01-01 00:00:00+01:00"]

In [8]:  pd.to_datetime(data, utc=False)
Out[8]:
Index([2020-01-01 00:00:00+06:00, 2020-01-01 00:00:00+01:00], dtype='object') 

新行为

In [9]: pd.to_datetime(data, utc=False)
FutureWarning:
 In a future version of pandas, parsing datetimes with mixed time zones will raise
 a warning unless `utc=True`. Please specify `utc=True` to opt in to the new behaviour
 and silence this warning. To create a `Series` with mixed offsets and `object` dtype,
 please use `apply` and `datetime.datetime.strptime`.
Index([2020-01-01 00:00:00+06:00, 2020-01-01 00:00:00+01:00], dtype='object') 

为了消除此警告并避免 pandas 未来版本中的错误,请指定 utc=True

In [29]: data = ["2020-01-01 00:00:00+06:00", "2020-01-01 00:00:00+01:00"]

In [30]: pd.to_datetime(data, utc=True)
Out[30]: DatetimeIndex(['2019-12-31 18:00:00+00:00', '2019-12-31 23:00:00+00:00'], dtype='datetime64[ns, UTC]', freq=None) 

要创建具有混合偏移和 object dtype 的 Series,请使用 applydatetime.datetime.strptime

In [31]: import datetime as dt

In [32]: data = ["2020-01-01 00:00:00+06:00", "2020-01-01 00:00:00+01:00"]

In [33]: pd.Series(data).apply(lambda x: dt.datetime.strptime(x, '%Y-%m-%d %H:%M:%S%z'))
Out[33]: 
0    2020-01-01 00:00:00+06:00
1    2020-01-01 00:00:00+01:00
dtype: object 

其他废弃内容

  • 废弃 DataFrameGroupBy.dtypes,请检查底层对象的 dtypes 代替(GH 51045

  • 废弃 DataFrame._dataSeries._data,请使用公共 API 代替(GH 33333

  • 废弃 concat() 的行为,当被连接的任何对象的长度为 0 时;过去,在确定结果 dtype 时会忽略空对象的 dtypes,在将来的版本中将不再忽略。

  • 废弃 Categorical.to_list(),请使用 obj.tolist() 替代(GH 51254

  • 在具有 datetime64 或 PeriodDtype 值的情况下,已弃用 DataFrameGroupBy.all()DataFrameGroupBy.any(),与 SeriesDataFrame 弃用相匹配(GH 34479

  • DataFrame.ewm()DataFrame.rolling()DataFrame.expanding() 中已弃用 axis=1,在调用方法前请进行转置(GH 51778

  • DataFrame.groupby()Grouper 构造函数中已弃用 axis=1,请使用 frame.T.groupby(...) 代替(GH 51203

  • Series.align()DataFrame.align() 中已弃用 broadcast_axis 关键字,在调用 align 前将其转换为 left = DataFrame({col: left for col in right.columns}, index=right.index)GH 51856

  • Index.fillna() 中已弃用 downcast 关键字(GH 53956

  • DataFrame.pct_change()Series.pct_change()DataFrameGroupBy.pct_change()SeriesGroupBy.pct_change()中,已弃用fill_methodlimit关键词,调用例如DataFrame.ffill()DataFrame.bfill()以在调用pct_change之前明确填充数据。(GH 53491)

  • DataFrame.align()Series.align()中,已弃用methodlimitfill_axis关键词,需明确在对齐结果上调用DataFrame.fillna()Series.fillna()代替。(GH 51856)

  • Rolling.quantile()Expanding.quantile()中,已弃用quantile关键词,改为使用q代替。(GH 52550)

  • DataFrame.take()中,不再接受切片,需调用obj[slicer]或传递整数序列代替。(GH 51539)

  • 已弃用DataFrame.idxmax()DataFrame.idxmin()Series.idxmax()Series.idxmin()在所有 NA 条目或任何 NA 和 skipna=False 时的行为;在将来的版本中,这些将引发 ValueErrorGH 51276)

  • 已弃用显式支持子类化IndexGH 45289)

  • 将给定给Series.agg()的已弃用的制作函数尝试对Series中的每个元素进行操作,仅在元素级操作失败时才对整个Series进行操作。将来,给定给Series.agg()的函数将始终仅对整个Series进行操作。要保持当前行为,请改用Series.transform()代替(GH 53325)

  • 已弃用使给定给DataFrame.agg()的函数列表中的函数尝试对DataFrame中的每个元素进行操作,并仅在元素级操作失败时才对DataFrame的列进行操作。要保持当前行为,请改用DataFrame.transform()代替(GH 53325)

  • 已弃用将DataFrame传递给DataFrame.from_records(),请改用DataFrame.set_index()DataFrame.drop()代替(GH 51353)

  • 在将字符串解析为日期时间时,弃用了默默丢弃未识别时区的行为(GH 18702)

  • DataFrame.ewm(), Series.ewm(), DataFrame.rolling(), Series.rolling(), DataFrame.expanding(), Series.expanding() 函数中弃用了 axis 关键字(GH 51778)

  • DataFrame.resample(), Series.resample() 函数中弃用了 axis 关键字(GH 51778)

  • Series.interpolate(), DataFrame.interpolate(), Series.fillna(), DataFrame.fillna(), Series.ffill(), DataFrame.ffill(), Series.bfill(), DataFrame.bfill() 函数中弃用了 downcast 关键字(GH 40988)

  • concat() 函数中弃用了当 len(keys) != len(objs) 时的行为,在将来的版本中将会引发异常,而不是截断到两个序列中较短的一个(GH 43485)

  • 在存在 NA 值时,弃用了 Series.argsort() 函数的行为;在将来的版本中,这些值将被放在末尾,而不是给出 -1(GH 54219)

  • DataFrame.groupby()Series.groupby()中弃用了observed=False的默认设置;在将来的版本中,这将默认为TrueGH 43999

  • SeriesGroupBy.aggregate()聚合中取消了将group.name固定到每个组的操作;如果您的操作需要使用 groupby 键,请遍历 groupby 对象而不是固定 group.name(GH 41090

  • DataFrameGroupBy.idxmax(), DataFrameGroupBy.idxmin(), DataFrameGroupBy.fillna(), DataFrameGroupBy.take(), DataFrameGroupBy.skew(), DataFrameGroupBy.rank(), DataFrameGroupBy.cumprod(), DataFrameGroupBy.cumsum(), DataFrameGroupBy.cummax(), DataFrameGroupBy.cummin(), DataFrameGroupBy.pct_change(), DataFrameGroupBy.diff(), DataFrameGroupBy.shift(), 和 DataFrameGroupBy.corrwith() 中弃用了 axis 关键字;对于 axis=1 则在底层的 DataFrame 上进行操作 (GH 50405, GH 51046)

  • DataFrameGroupBy 中,使用 as_index=False 时废弃了不包含 DataFrame 中未列为列的分组的结果 (GH 49519)

  • 废弃了 is_categorical_dtype(),改用 isinstance(obj.dtype, pd.CategoricalDtype) 代替 (GH 52527)

  • 废弃了 is_datetime64tz_dtype(),改用 isinstance(dtype, pd.DatetimeTZDtype) 进行检查 (GH 52607)

  • 废弃了 is_int64_dtype(),改用 dtype == np.dtype(np.int64) 进行检查 (GH 52564)

  • 废弃了 is_interval_dtype(),改用 isinstance(dtype, pd.IntervalDtype) 进行检查 (GH 52607)

  • 废弃了 is_period_dtype(),改用 isinstance(dtype, pd.PeriodDtype) 进行检查 (GH 52642)

  • 废弃了 is_sparse(),改用 isinstance(dtype, pd.SparseDtype) 进行检查 (GH 52642)

  • 废弃了 Styler.applymap_index()。请使用新的 Styler.map_index() 方法代替 (GH 52708)

  • 废弃了 Styler.applymap()。请使用新的 Styler.map() 方法代替 (GH 52708)

  • 废弃了 DataFrame.applymap()。请使用新的 DataFrame.map() 方法代替 (GH 52353)

  • 废弃了 DataFrame.swapaxes()Series.swapaxes(),改用 DataFrame.transpose()Series.transpose() 代替 (GH 51946)

  • PeriodArray 构造函数中废弃了 freq 参数,请传递 dtype 代替 (GH 52462)

  • take()弃用非标准输入的允许,传递一个 numpy.ndarrayExtensionArrayIndexSeries 中的一种 (GH 52981)

  • isin()value_counts()unique()factorize()弃用非标准序列的允许,调用之前将序列转换为 numpy.ndarrayIndexExtensionArraySeries 中的一种 (GH 52986)

  • DataFrame 进行 sumprodstdvarsem弃用行为,且 axis=None 时,在将来的版本中,这将同时作用于两个轴,返回标量而不是像 axis=0 一样的行为;注意这也会影响 numpy 函数,例如 np.sum(df)GH 21597

  • DataFrame 的列全部为 NA 时,concat()弃用行为,在将来的版本中,这些列将不会在确定结果 dtype 时被丢弃(GH 40893

  • Series.dt.to_pydatetime()弃用行为,在将来的版本中,这将返回一个包含 python datetime 对象而不是 datetimes 的 ndarraySeries;这与其他 Series.dt 属性的行为一致(GH 20306

  • 在 pandas 对象和无 dtype 序列(例如 listtuple)之间的弃用逻辑操作(|, &, ^),在操作之前将序列包装在一个 Series 或 NumPy 数组中 (GH 51521)

  • Series.apply() 中弃用了参数 convert_typeGH 52140

  • 弃用了将字典传递给 SeriesGroupBy.agg() 的方式,请传递聚合列表代替(GH 50684

  • Categorical 构造函数中弃用了 fastpath 关键字,请使用 Categorical.from_codes() 代替(GH 20110

  • 弃用了 is_bool_dtype() 方法对布尔对象的 object-dtype Index 返回 True 的行为(GH 52680

  • 弃用了方法 Series.bool()DataFrame.bool()GH 51749

  • DatetimeIndex 构造函数中弃用了未使用的 closednormalize 关键字(GH 52628

  • TimedeltaIndex 构造函数中弃用了未使用的 closed 关键字(GH 52628

  • 弃用了两个不同索引的非布尔 Series 之间的逻辑操作,始终强制将结果转换为布尔类型。在将来的版本中,这将保持输入的返回类型(GH 52500GH 52538

  • 弃用了带有 BDay 频率的 PeriodPeriodDtype,请使用带有 BDay 频率的 DatetimeIndex 代替(GH 53446

  • 弃用了 value_counts(),请使用 pd.Series(obj).value_counts() 代替(GH 47862

  • 弃用了 Series.first()DataFrame.first();请使用 .loc 创建掩码并进行过滤(见 GH 45908

  • 弃用了对象类型的 Series.interpolate()DataFrame.interpolate()(见 GH 53631

  • 弃用了 Series.last()DataFrame.last();请使用 .loc 创建掩码并进行过滤(见 GH 53692

  • 弃用了在 SparseDtype 中允许任意 fill_value 的行为,在未来版本中,fill_value 将需要与 dtype.subtype 兼容,即可以由该 subtype 所持有的标量或用于整数或布尔子类型的 NaN(见 GH 23124

  • 弃用了在 DataFrameGroupBy.quantile()SeriesGroupBy.quantile() 中允许 bool 类型的行为,与 Series.quantile()DataFrame.quantile() 的行为一致(见 GH 51424

  • 弃用了在 testing.assert_series_equal()testing.assert_frame_equal() 中考虑 NA 值(例如 NaNNone 视为等价)的行为(见 GH 52081

  • 弃用了将字节输入到 read_excel() 中的行为。要读取文件路径,请使用字符串或类似路径的对象(见 GH 53767

  • 废弃了从标量数据构造SparseArray,改为传递一个序列 (GH 53039)

  • to_replace不像字典一样时,废弃了在DataFrame.replace()Series.replace()中当value未指定时的填充回退 (GH 33302)

  • 废弃了read_json()的字面 json 输入。改为在io.StringIO中包装字面 json 字符串输入 (GH 53409)

  • 废弃了字面字符串输入到read_xml()。改为在io.StringIO / io.BytesIO中包装字面字符串/字节输入 (GH 53767)

  • 废弃了read_html()的字面字符串/字节输入。改为在io.StringIO / io.BytesIO中包装字面字符串/字节输入 (GH 53767)

  • 废弃了选项mode.use_inf_as_na,在之前将 inf 条目转换为NaN (GH 51684)

  • 废弃了DataFrameGroupBy.get_group()中的参数obj (GH 53545)

  • 废弃了使用Series.__getitem__()Series.__setitem__()Series上的位置索引,在将来版本中,ser[item]始终解释item为标签,而不是位置 (GH 50617)

  • 废弃了在.agg.apply.transform中替换内置和 NumPy 函数的方法;使用相应的字符串别名(例如"sum"代替sumnp.sum)替代 (GH 53425)

  • 废弃了字符串TtLlto_timedelta()中表示单位 (GH 52536)

  • 废弃了在.ExtensionArray.fillna中的“method”和“limit”关键字,改为实现_pad_or_backfill (GH 53621)

  • 弃用了 DataFrame.replace()Series.replace() 方法中的 methodlimit 关键字(GH 33302)

  • 弃用了Series.fillna()DataFrame.fillna()SeriesGroupBy.fillna()DataFrameGroupBy.fillna()Resampler.fillna() 方法中的 methodlimit 关键字,请改用 obj.bfill()obj.ffill() 代替(GH 53394)

  • 弃用了对具有浮点型索引的对象上的 Series.__getitem__()Series.__setitem__()DataFrame.__getitem__()DataFrame.__setitem__() 方法使用整数切片的行为,在未来版本中,这将被视为位置索引(GH 49612)

  • 弃用了在 pandas.array() 方法中使用不支持的 datetime64 和 timedelta64 分辨率。支持的分辨率有:"s"、"ms"、"us"、"ns"(GH 53058)

  • 弃用了 Series.interpolate()DataFrame.interpolate() 方法中的值 "pad""ffill""bfill""backfill",请改用 obj.ffill()obj.bfill() 代替(GH 53581)

  • 已弃用Index.argmax()Index.argmin()Series.argmax()Series.argmin()方法在所有-NAs 且skipna=True或任何-NAs 且skipna=False时返回-1 的行为;在将来的版本中,这将引发ValueError (GH 33941, GH 33942)

  • 已弃用在DataFrame.to_sql()中允许非关键字参数,除了namecon之外的参数 (GH 54229)

  • 在将freqfill_value同时传递给DataFrame.shift()Series.shift()DataFrameGroupBy.shift()时,已弃用对fill_value的静默忽略;在将来的版本中,这将引发ValueError (GH 53832) ## 性能改进

  • 在具有同类的np.float64np.float32数据类型的concat()中的性能改进 (GH 52685)

  • 对不包含字符串的对象列进行factorize()的性能改进 (GH 51921)

  • 在读取远程 URI 文件路径时,read_orc()的性能改进 (GH 51609)

  • 在使用engine="pyarrow"读取远程文件时,read_parquet()DataFrame.to_parquet()的性能改进 (GH 51609)

  • 在使用use_nullable_dtypes=True时,read_parquet()中字符串列的性能改进 (GH 47345)

  • DataFrame.clip()Series.clip()中的性能改进(GH 51472

  • 当给定items时,在DataFrame.filter()中的性能改进(GH 52941

  • 在扩展数组数据类型的DataFrame.first_valid_index()DataFrame.last_valid_index()中的性能改进(GH 51549

  • cond由扩展数据类型支持时,在DataFrame.where()中的性能改进(GH 51574

  • verify_integrity=True时,MultiIndex.set_levels()MultiIndex.set_codes()中的性能改进(GH 51873

  • ascending是列表时,MultiIndex.sortlevel()中的性能改进(GH 51612

  • Series.combine_first()中的性能改进(GH 51777

  • 当数组不包含空值时,在fillna()中的性能改进(GH 51635

  • 当数组没有空值或全部为空值时,在isna()中的性能改进(GH 51630

  • 当将字符串解析为boolean[pyarrow]数据类型时的性能改进(GH 51730

  • Index从其他索引切片时的性能改进(GH 51738

  • concat()中的性能改进(GH 52291GH 52290

  • Period的默认格式化器(period_format)现在显著(~两倍)更快。这提升了str(Period)repr(Period)Period.strftime(fmt=None)的性能,以及.PeriodArray.strftime(fmt=None).PeriodIndex.strftime(fmt=None).PeriodIndex.format(fmt=None)。涉及默认date_formatPeriodArrayPeriodIndexto_csv操作也显著加快了(GH 51459

  • 访问arrays.IntegerArrays.dtypearrays.FloatingArray.dtype的性能提升(GH 52998

  • DataFrameGroupBy/SeriesGroupBy聚合操作(例如 DataFrameGroupBy.sum())在使用 engine="numba" 时的性能提升(GH 53731

  • 在带有 axis=1 和扩展数据类型的DataFrame缩减中的性能提升(GH 54341

  • 带有axis=None和扩展数据类型的DataFrame缩减中的性能提升(GH 54308

  • 在索引/列值已经排序时的MultiIndex和多列操作中的性能提升(例如 DataFrame.sort_values()DataFrame.groupby()Series.unstack())(GH 53806

  • Series缩减操作中的性能提升(GH 52341

  • concat()中当axis=1且对象具有不同索引时的性能提升(GH 52541

  • 当连接轴是 MultiIndex 时,concat() 的性能改进(GH 53574

  • PyArrow 支持的字符串在 merge() 中的性能改进(GH 54443

  • 使用 engine="c" 时,read_csv() 的性能改进(GH 52632

  • ArrowExtensionArray.to_numpy() 的性能改进(GH 52525

  • DataFrameGroupBy.groups() 的性能改进(GH 53088

  • dtype 是扩展数据类型时,DataFrame.astype() 的性能改进(GH 54299

  • 当输入为单个整数且数据框由扩展数据类型支持时,DataFrame.iloc() 的性能改进(GH 54508

  • 对扩展数据类型的 DataFrame.isin() 的性能改进(GH 53514

  • 在选择行和列时,DataFrame.loc() 的性能改进(GH 53014

  • 在转置具有单个 PyArrow 数据类型的数据框时,DataFrame.transpose() 的性能改进(GH 54224

  • 在转置具有单个掩码数据类型(例如 Int64)的数据框时,DataFrame.transpose() 的性能改进(GH 52836

  • 对 PyArrow 字符串和二进制数据类型的 Series.add() 的性能改进(GH 53150

  • 改进了在扩展数据类型上的 Series.corr()Series.cov() 方法的性能(GH 52502)。

  • 改进了在 ArrowDtype 上的 Series.drop_duplicates() 方法的性能(GH 54667)。

  • 在 PyArrow 数据类型上使用 Series.ffill()Series.bfill()DataFrame.ffill()DataFrame.bfill() 方法时,性能有所提升(GH 53950)。

  • 在 PyArrow 支持的字符串上使用 Series.str.get_dummies() 方法时,性能得到改进(GH 53655)。

  • 改进了在 PyArrow 支持的字符串上的 Series.str.get() 方法的性能(GH 53152)。

  • 改进了 Series.str.split() 使用 expand=True 参数在 PyArrow 支持的字符串上的性能(GH 53585)。

  • 当数据类型为 NumPy 浮点数据类型且 na_valuenp.nan 时,Series.to_numpy() 的性能有所提升(GH 52430)。

  • 在从 PyArrow 时间戳或持续时间数据类型转换为 NumPy 时,改进了 astype() 的性能(GH 53326)。

  • 在各种 MultiIndex 设置和索引操作中,性能得到提升(GH 53955)。

  • 在对 arrays.IntegerArrayarrays.FloatingArray 进行各种重塑操作时,通过避免进行不必要的验证,性能有所改善(GH 53013)。

  • 使用 PyArrow 时间戳和持续时间 dtypes 进行索引时的性能提升(GH 53368)。

  • 当将数组传递给 RangeIndex.take()DataFrame.loc()DataFrame.iloc(),并且 DataFrame 使用 RangeIndex 时,对性能进行了改进(GH 53387)。

Categorical

  • CategoricalIndex.remove_categories() 中存在一个错误,其中有序类别将不会被维护(GH 53935)。

  • dtype="category" 的情况下,使用 Series.astype() 时出现错误,对于具有只读空值掩码的可空数组(GH 53658)。

  • Series.map() 中存在一个错误,如果系列持有一个 Categorical,则 na_action 参数的值将不会被使用(GH 22527)。

Datetimelike

  • DatetimeIndex.map()na_action="ignore" 现在按预期工作(GH 51644)。

  • DatetimeIndex.slice_indexer() 现在对非单调索引引发 KeyError,如果切片边界之一不在索引中;此行为先前已被弃用,但处理不一致(GH 53983)。

  • 在乘以常数时,DateOffset 的行为不一致(GH 47953)。

  • freq 是带有 nanosecondsDateOffset 时,在 date_range() 中存在一个错误(GH 46877)。

  • to_datetime() 转换包含 PyArrow 时间戳的 SeriesDataFrame 到 numpy datetimes 时出现错误,这些时间戳是 arrays.ArrowExtensionArrayGH 52545)。

  • DatetimeArray.map()DatetimeIndex.map()中的错误,其中提供的可调用对象是数组级别的操作而不是元素级别的操作(GH 51977

  • 在使用 PyArrow 支持的日期类型时,DataFrame.to_sql()引发ValueError的错误(GH 53854

  • Timestamp.date()Timestamp.isocalendar()Timestamp.timetuple()Timestamp.toordinal()中的错误,对于超出 Python 标准库的 datetime 模块支持范围的输入,返回的结果不正确(GH 53668

  • Timestamp.round()中的错误,在接近实现边界的值返回不正确的结果,而不是引发OutOfBoundsDatetimeGH 51494

  • 从日期时间或时间差标量构造SeriesDataFrame的错误,总是推断出纳秒分辨率而不是根据输入推断(GH 52212

  • 从表示时间而不带日期的字符串构造Timestamp的错误,推断出不正确的单位(GH 54097

  • 使用ts_input=pd.NA构造Timestamp引发TypeError的错误(GH 45481

  • 解析带有工作日但没有日期的日期时间字符串的错误,例如“2023 年 9 月星期四”,错误地引发AttributeError而不是ValueErrorGH 52659

  • 当 dtype 是带有非纳秒分辨率的时区感知日期时间时,Series的 repr 中存在错误,引发OutOfBoundsDatetimeGH 54623

时间差

  • TimedeltaIndex 的除法或乘法导致 .freq 为“0 天”而不是 None 的问题(GH 51575)

  • Bug in Timedelta 中 NumPy timedelta64 对象未能正确引发 ValueError 的问题(GH 52806)

  • Bug in to_timedelta() 将包含 pyarrow.durationSeriesDataFrame 转换为 NumPy timedelta64 时出现问题(GH 54298)

  • Timedelta.__hash__() 中的问题,在某些大秒分辨率值上引发 OutOfBoundsTimedeltaGH 54037)

  • Bug in Timedelta.round() 对接近实现边界的值返回不正确结果而不是引发 OutOfBoundsTimedelta 的问题(GH 51494)

  • TimedeltaIndex.map() 中带有 na_action="ignore" 的问题(GH 51644)

  • arrays.TimedeltaArray.map()TimedeltaIndex.map() 中的问题,提供的可调用函数是数组级别操作而不是元素级别操作(GH 51977)

时区

  • Bug in infer_freq() 对带有时区信息的时间戳 Series 引发 TypeError 的问题(GH 52456)

  • DatetimeTZDtype.base() 总是返回具有纳秒分辨率的 NumPy 数据类型的问题(GH 52705)

数值

  • Bug in RangeIndex 在被减数为数值时,设置 step 不正确的问题(GH 53255)

  • Bug in Series.corr()Series.cov() 对带有掩码数据类型的对象引发 AttributeError 的问题(GH 51422)

  • 在调用全零 NumPy 数据的 Series.kurt()Series.skew() 时返回 Python 类型而不是 NumPy 类型的 Bug (GH 53482)

  • 在包含可以转换为数字的字符串(例如“2”)的 object-dtype 值的 Series.mean()DataFrame.mean() 存在的 Bug 导致返回不正确的数值结果;现在这些会引发 TypeError (GH 36703, GH 44008)

  • 在 PyArrow-backed dtypes 上调用 DataFrame.corrwith() 时出现 NotImplementedError 的 Bug (GH 52314)

  • 在调用 DataFrame.size()Series.size() 时,返回 64 位整数而不是 Python int 的 Bug (GH 52897)

  • DateFrame.dot() 中存在的 Bug 导致对 ArrowDtype 数据返回 object 数据类型(GH 53979)

  • Series.any()Series.all()DataFrame.any()DataFrame.all() 中,默认值 bool_only 设置为 None 而不是 False 的 Bug;这个改变对用户没有影响 (GH 53258)

  • 在调用 Series.corr()Series.cov() 时,对于 masked dtypes 抛出 AttributeError 的 Bug (GH 51422)

  • Series.median()DataFrame.median() 中的错误,包含可转换为数字的字符串的 object-dtype 值(例如“2”)返回不正确的数值结果;现在会引发 TypeErrorGH 34671

  • Series.sum() 中的错误,将 uint64 转换为 int64 类型(GH 53401

转换

  • 如果 DataFrame 包含比浮点双精度浮点数能表示的更多位数的整数,则 DataFrame.style.to_latex()DataFrame.style.to_html() 中的错误(GH 52272

  • 在给定单位为“s”、“us”或“ms”的 datetime64timedelta64 类型时,array() 中的错误返回 NumpyExtensionArray 而不是 DatetimeArrayTimedeltaArrayGH 52859

  • 在给定空列表且没有 dtype 的情况下,array() 中的错误返回 NumpyExtensionArray 而不是 FloatingArrayGH 54371

  • ArrowDtype.numpy_dtype() 中的错误,对于非纳秒 pyarrow.timestamppyarrow.duration 类型返回纳秒单位(GH 51800

  • DataFrame.__repr__() 中的错误,当列的 dtype 为 np.record 时错误地引发 TypeErrorGH 48526

  • DataFrame.info() 中的错误,在设置 use_numba 时引发 ValueErrorGH 51922

  • DataFrame.insert() 中的错误,如果 locnp.int64 则引发 TypeError([GH 53193](https://github.com/pandas-dev/pandas/issues/53193)

  • HDFStore.select()中的错误,在存储和检索时,会丢失大整数的精度(GH 54186

  • Series.astype()中的错误,不支持 object_ 类型(GH 54251

字符串

  • Series.str()中的错误,迭代时未引发 TypeErrorGH 54173

  • DataFrame`` 的 repr` 中存在字符串类型列时的错误(GH 54797

区间

  • target 是只读数组时,IntervalIndex.get_indexer()IntervalIndex.get_indexer_nonunique() 会引发错误(GH 53703

  • IntervalDtype中的错误,在删除时对象可能会被保留(GH 54184

  • interval_range()中的错误,当浮点数 step 产生浮点数的副作用时,会产生不正确的间隔(GH 54477

索引

  • 当将一个 DataFrame 设置到重复列时,DataFrame.__setitem__() 丢失 dtype 中的错误(GH 53143

  • 在使用布尔掩码时,DataFrame.__setitem__()DataFrame.putmask() 对于混合非数值类型和除 NaN 之外的值会错误地引发 TypeErrorGH 53291

  • 在使用 nan 作为唯一元素时,DataFrame.iloc()中的错误(GH 52234

  • Series.loc()中的错误,在将预定义索引的 object 类型的 Series 分配给 Series 时将 Series 强制转换为 np.dnarrayGH 48933

缺失

  • method"pad""ffill""bfill""backfill" 时,DataFrame.interpolate() 未能填充数据(GH 53898)

  • DataFrame 为空时,DataFrame.interpolate() 忽略了 inplaceGH 53199)

  • Series.idxmin()Series.idxmax()DataFrame.idxmin()DataFrame.idxmax() 在包含 NaTDatetimeIndex 索引中的错误,将错误地返回 NaN 而不是 NaTGH 43587)

  • 在无效的 downcast 关键字上,Series.interpolate()DataFrame.interpolate() 未能引发错误,此关键字只能为 None"infer"GH 53103)

  • 具有复杂数据类型的 Series.interpolate()DataFrame.interpolate() 错误地未能填充 NaN 条目(GH 53635)

MultiIndex

  • MultiIndex.set_levels() 中的错误未保留 Categorical 的数据类型(GH 52125)

  • 显示长元素的 MultiIndex 时出现的错误(GH 52960)

I/O

  • DataFrame.to_orc() 函数现在在给定非默认 Index 时引发 ValueError (GH 51828)

  • DataFrame.to_sql() 函数在使用 SQLAlchemy 连接时未提供 name 参数时会引发 ValueError (GH 52675)

  • json_normalize() 函数无法解析元数据字段列表类型 (GH 37782)

  • read_csv() 函数在将 parse_dates 设置为列表或字典且使用 engine="pyarrow" 时会出错 (GH 47961)

  • read_csv() 函数在使用 engine="pyarrow" 并指定 index_col 时引发错误 (GH 53229)

  • read_hdf() 函数在引发 IndexError 后未正确关闭存储 (GH 52781)

  • read_html() 函数错误地将样式元素读取为 DataFrame (GH 52197)

  • read_html() 函数在与包含 display:none 样式的元素一起删除尾部文本时发生错误 (GH 51629)

  • read_sql_table() 函数在读取视图时引发异常 (GH 52969)

  • read_sql() 函数在读取具有相同列名的多个时区感知列时出错 (GH 44421)

  • read_xml() 函数会剥离字符串数据中的空格 (GH 53811)

  • DataFrame.to_html() 函数在多级索引列情况下错误地应用了 colspace (GH 53885)

  • DataFrame.to_html()中的错误,当空的DataFrame具有复杂 dtype 时引发ValueErrorGH 54167)

  • DataFrame.to_json()中的错误,DateTimeArray/DateTimeIndex��有非纳秒精度时无法正确序列化(GH 53686)

  • 写入和读取空的 Stata dta 文件时丢失 dtype 信息的错误(GH 46240)

  • bz2视为硬性要求的错误(GH 53857)

期间

  • PeriodDtype构造函数在不传递参数或传递None时未能引发TypeError的错误(GH 27388)

  • PeriodDtype构造函数在不同的DateOffset freq输入下错误地返回相同的normalizeGH 24121)

  • PeriodDtype构造函数在传递无效类型时引发ValueError而不是TypeError的错误(GH 51790)

  • PeriodDtype中的错误,当删除时对象可能仍保持活动状态(GH 54184)

  • read_csv()中的错误,不将空字符串处理为 null 值,使用engine="pyarrow"时(GH 52087)

  • read_csv()中的错误,使用engine="pyarrow"时,将所有空列返回为object dtype 列而不是float64 dtype 列,对于所有使用engine="pyarrow"的空列(GH 52087)

  • Period.now()中的错误,不接受freq参数作为关键字参数(GH 53369)

  • PeriodIndex.map()中的错误,使用na_action="ignore"时(GH 51644)

  • arrays.PeriodArray.map()PeriodIndex.map()中的错误,提供的可调用函数是数组级别操作而不是元素级别操作(GH 51977)

  • 在错误地允许使用 CustomBusinessDay 频率构造 PeriodPeriodDtype 时存在的错误;请改用 BusinessDay (GH 52534)

绘图

  • 当以 color=None 调用时,在 Series.plot() 中存在的错误 (GH 51953)

  • 在以 c="b" 调用时,修复了 DataFrame.plot.scatter() 中的 UserWarning (GH 53908)

Groupby/resample/rolling

  • 当在空 DataFrameGroupBy 或 SeriesGroupBy 上使用时,DataFrameGroupBy.idxmin()SeriesGroupBy.idxmin()DataFrameGroupBy.idxmax()SeriesGroupBy.idxmax() 返回错误的数据类型 (GH 51423)

  • 在传递 na_option="bottom"na_option="top" 时,可空数据类型上存在的 DataFrame.groupby.rank() 中的错误 (GH 54206)

  • 在在 TimedeltaIndex 上重新采样时,错误地允许非固定 freqDataFrame.resample()Series.resample() 中的错误 (GH 51896)

  • 在重新采样空数据时,DataFrame.resample()Series.resample() 中丢失时区的错误 (GH 53664)

  • DataFrame.resample()Series.resample()中存在的 bug,当值在轴外时,origin 在重新采样时没有效果(GH 53662)

  • 在指定 min_periods=0 时,加权滚动聚合中存在的 bug(GH 51449)

  • DataFrame.groupby()Series.groupby()中存在的 bug,当分组的SeriesDataFrame的索引是DatetimeIndexTimedeltaIndexPeriodIndex时,且groupby方法的第一个参数是函数时,该函数会作用于整个索引而不是索引的每个元素(GH 51979)

  • DataFrameGroupBy.agg()中存在的 bug,列表��遵守 as_index=FalseGH 52849)

  • DataFrameGroupBy.apply()中存在的 bug,当输入的DataFrame在 groupby 后被子集化为DataFrame[['a']] 而不是 ['a']),并且给定的可调用函数返回的Series不是全部具有相同索引时,会引发错误(GH 52444)

  • DataFrameGroupBy.apply()中存在的 bug,当选择多列并提供返回np.ndarray结果的函数时,会引发 TypeError 错误(GH 18930)

  • DataFrameGroupBy.groups()SeriesGroupBy.groups() 中的 Bug,在与另一个键一起使用日期时间键时,会产生不正确的分组键数量(GH 51158

  • DataFrameGroupBy.quantile()SeriesGroupBy.quantile() 中的 Bug 可能会在 sort=False 的情况下隐式对结果索引进行排序(GH 53009

  • SeriesGroupBy.size() 中的 Bug,对于具有 ArrowDtype 或掩码数据类型(例如 Int64)的数据,dtype 将为 np.int64GH 53831

  • DataFrame.groupby() 中的 Bug,在结果 groupby 对象上进行列选择时,当通过由单个元素组成的列表进行分组时,不返回元组名称(GH 53500

  • DataFrameGroupBy.var()SeriesGroupBy.var() 中的 Bug,在使用 datetime64、timedelta64 或 PeriodDtype 值时未能引发 TypeErrorGH 52128GH 53045)

  • DataFrameGroupBy.resample() 中的 Bug,在 kind="period" 时引发 AttributeErrorGH 24103

  • Resampler.ohlc() 中存在错误,当返回空对象时返回 Series 而不是空的 DataFrame (GH 42902)

  • 在具有 ArrowDtype 或掩码数据类型(例如 Int64)的数据中,SeriesGroupBy.count()DataFrameGroupBy.count() 的 dtype 将为 np.int64 (GH 53831)

  • 在使用 dropna="any"dropna="all" 进行列选择后,SeriesGroupBy.nth()DataFrameGroupBy.nth() 存在错误,不会对列进行子集划分 (GH 53518)

  • 在使用 dropna="any"dropna="all" 进行列选择后,SeriesGroupBy.nth()DataFrameGroupBy.nth() 存在错误,导致行被删除 (GH 53518)

  • SeriesGroupBy.sum()DataFrameGroupBy.sum() 存在错误,将 np.inf + np.inf(-np.inf) + (-np.inf) 合计为 np.nan 而不是分别为 np.inf-np.inf (GH 53606)

  • Series.groupby() 中的错误,当分组的 Series 具有 DatetimeIndex 索引和名称为月份的 Series 被给定到 by 参数时会引发错误(GH 48509

重塑

  • concat() 中的错误,当一列具有 pa.null() 数据类型时,会强制转换为 object 数据类型(GH 53702

  • crosstab() 中的错误,当 dropna=False 时不会在结果中保留 np.nanGH 10772

  • melt() 中的错误,variable 列会丢失扩展数据类型(GH 54297

  • merge_asof() 中的错误,当扩展的数据类型引发 KeyError 时会抛出异常(GH 52904

  • merge_asof() 中的错误,当数据由只读的 ndarrays 支持时会引发 ValueErrorGH 53513

  • merge_asof() 中的错误,在某些情况下,当 left_index=Trueright_index=True 且索引类型不匹配时,会返回不正确的结果而不是引发 MergeErrorGH 53870

  • merge() 中的错误,当在整数 ExtensionDtype 和浮点数 NumPy 数据类型上合并时会引发 TypeErrorGH 46178

  • DataFrame.agg()Series.agg() 中的错误,当非唯一列传递 dist-like 参数时,返回的类型不正确(GH 51099

  • DataFrame.combine_first() 中的错误,如果 other 是空的,则会忽略其他列(GH 53792

  • DataFrame.idxmin()DataFrame.idxmax()中存在错误,当帧为空时,轴的 dtype 会丢失(GH 53265

  • DataFrame.merge()中存在错误,当具有单级MultiIndex时无法正确合并(GH 52331

  • DataFrame.stack()中存在错误,当列是MultiIndex且帧包含混合 dtype 时,会丢失扩展 dtype(GH 45740

  • DataFrame.stack()中存在错误,对列进行字典排序(GH 53786

  • DataFrame.transpose()中存在错误,为对象列推断 dtype 时出现错误(GH 51546

  • Series.combine_first()中存在错误,将int64 dtype 转换为float64并丢失非常大整数的精度(GH 51764

  • 在连接空DataFrame对象时存在错误,连接的索引将是RangeIndex而不是连接的索引类型(GH 52777

稀疏

  • SparseDtype构造函数中存在错误,当给定不兼容的dtype作为其子类型时,未能引发TypeError,其子类型必须是 NumPy 的 dtype(GH 53160

  • arrays.SparseArray.map()中存在错误,允许填充值包含在稀疏值中(GH 52095

扩展数组

  • ArrowStringArray构造函数中存在错误,当使用字符串字典类型时引发ValueErrorGH 54074

  • 在给定字典时,DataFrame构造函数不会复制具有扩展 dtype 的Series的错误(GH 53744

  • 将 pandas 非纳秒时间对象从非零值转换为零值的ArrowExtensionArray中存在错误(GH 53171

  • 在 PyArrow 时间类型中引发 ArrowInvalidSeries.quantile()中存在错误(GH 52678

  • 对于具有Float64 dtype 的小值,Series.rank()返回错误的顺序的错误(GH 52471

  • 在带有NA值的布尔ArrowDtypeSeries.unique()中存在错误(GH 54667

  • 对于非纳秒 dtype,__iter__()__getitem__()返回 python datetime 和 timedelta 对象的错误(GH 53326

  • 对于具有多个块的pyarrow.dictionary类型的pyarrow.chunked_arrayfactorize()返回不正确的唯一值的错误(GH 54844

  • ExtensionArray子类传递给dtype关键字时的错误。现在将引发UserWarning以鼓励传递实例而不是类(GH 31356GH 54592

  • 当列具有pyarrow.ExtensionDtype并且具有pyarrow.dictionary类型的pyarrow.chunked_array时,DataFrame的 repr 无法工作的错误(GH 54063

  • 掩码的 ExtensionDtypes 的__from_arrow__方法(例如Float64DtypeBooleanDtype)不接受pyarrow.null()类型的 PyArrow 数组的错误(GH 52223

Styler

  • 在调用Styler子类中的重写方法时,在Styler._copy()中存在错误(GH 52728

元数据

  • DataFrame.max()DataFrame.min()DataFrame.prod()DataFrame.mean()Series.mode()DataFrame.median()DataFrame.sem()DataFrame.skew()DataFrame.kurt()中修复了元数据传播 (GH 28283)

  • DataFrame.squeeze()DataFrame.describe()中修复了元数据传播 (GH 28283)

  • DataFrame.std()中修复了元数据传播 (GH 28283)

其他

  • FloatingArray.__contains__ 中存在的 Bug,当存在 NaN 值时,NaN 项错误地返回 False (GH 52840)

  • DataFrameSeries中存在的 Bug,当存在 NaN 值时,为复杂 dtype 的数据引发异常 (GH 53627)

  • DatetimeIndex中存在的 Bug,其中当索引传递的 repr 带有时间时,不打印时间为午夜和非基于日的频率 (GH 53470)

  • testing.assert_frame_equal()testing.assert_series_equal()中存在的 Bug,现在为两个不相等的集合抛出断言错误 (GH 51727)

  • Bug in testing.assert_frame_equal() 在被要求不检查索引类型时仍检查类别 dtypes (GH 52126)

  • Bug in api.interchange.from_dataframe() 未遵守 allow_copy 参数(GH 54322)

  • Bug in api.interchange.from_dataframe() 在从非 pandas 时区感知数据中包含空值时引发错误(GH 54287)

  • Bug in api.interchange.from_dataframe() 在转换空的 DataFrame 对象时出现问题(GH 53155)

  • Bug in from_dummies() 中,生成的 Index 与原始 Index 不匹配(GH 54300)

  • Bug in from_dummies() 中,生成的数据始终为 object dtype 而不是列的 dtype (GH 54300)

  • Bug in DataFrameGroupBy.first(), DataFrameGroupBy.last(), SeriesGroupBy.first(), 和 SeriesGroupBy.last() 中,空组将返回 np.nan 而不是相应的 ExtensionArray NA 值(GH 39098)

  • 将整数的平均值转换回整数时,DataFrame.pivot_table()中的错误会导致转换错误(GH 16676)

  • 当应该使用ExtensionDtype推断fill_value时,DataFrame.reindex()中的错误错误地推断为object dtype(GH 52586)

  • 当在具有单个ExtensionDtype列的DataFrame上使用axis=1时,DataFrame.shift()中的错误会导致结果不正确(GH 53832)

  • 当传递key时,Index.sort_values()中的错误会导致错误(GH 52764)

  • 当使用 method=”asfreq”时,Series.align()DataFrame.align()Series.reindex()DataFrame.reindex()Series.interpolate()DataFrame.interpolate()中的错误未能引发错误(GH 53620)

  • 当传递无效的axis时,Series.argsort()中的错误未能引发错误(GH 54257)

  • 当对空系列提供可调用对象时,Series.map()中的错误会导致返回的系列具有object dtype。现在保留原始 dtype(GH 52384)

  • deep=True时,Series.memory_usage()中的错误会导致对象系列的错误和返回值不正确,因为它没有考虑 GC 修正(GH 51858)

  • period_range() 中存在 bug,当未传递 freq 参数时,默认行为是不正确的(GH 53687

  • 修正了 pandas._libs.json 的错误 __name__ 属性(GH 52898) ## 贡献者

共有 266 人为此版本贡献了补丁。名字后面带有“+”的人第一次为此贡献了补丁。

  • AG +

  • Aarni Koskela

  • Adrian D’Alessandro +

  • Adrien RUAULT +

  • Ahmad +

  • Aidos Kanapyanov +

  • Alex Malins

  • Alexander Seiler +

  • Ali Asgar +

  • Allison Kwan

  • Amanda Bizzinotto +

  • Andres Algaba +

  • Angela Seo +

  • Anirudh Hegde +

  • Antony Evmorfopoulos +

  • Anushka Bishnoi

  • ArnaudChanoine +

  • Artem Vorobyev +

  • Arya Sarkar +

  • Ashwin Srinath

  • Austin Au-Yeung +

  • Austin Burnett +

  • Bear +

  • Ben Mangold +

  • Bernardo Gameiro +

  • Boyd Kane +

  • Brayan Alexander Muñoz B +

  • Brock

  • Chetan0402 +

  • Chris Carini

  • ChristofKaufmann

  • Clark-W +

  • Conrad Mcgee Stocks

  • Corrie Bartelheimer +

  • Coulton Theuer +

  • D067751 +

  • Daniel Isaac

  • Daniele Nicolodi +

  • David Samuel +

  • David Seifert +

  • Dea Leon +

  • Dea María Léon

  • Deepyaman Datta

  • Denis Sapozhnikov +

  • Dharani Akurathi +

  • DimiGrammatikakis +

  • Dirk Ulbricht +

  • Dmitry Shemetov +

  • Dominik Berger

  • Efkan S. Goktepe +

  • Ege Özgüroğlu

  • Eli Schwartz

  • Erdi +

  • Fabrizio Primerano +

  • Facundo Batista +

  • Fangchen Li

  • Felipe Maion +

  • Francis +

  • Future Programmer +

  • Gabriel Kabbe +

  • Gaétan Ramet +

  • Gianluca Ficarelli

  • Godwill Agbehonou +

  • Guillaume Lemaitre

  • Guo Ci

  • Gustavo Vargas +

  • Hamidreza Sanaee +

  • HappyHorse +

  • Harald Husum +

  • Hugo van Kemenade

  • Ido Ronen +

  • Irv Lustig

  • JHM Darbyshire

  • JHM Darbyshire(iMac)

  • JJ +

  • Jarrod Millman

  • Jay +

  • Jeff Reback

  • Jessica Greene +

  • Jiawei Zhang +

  • Jinli Xiao +

  • Joanna Ge +

  • Jona Sassenhagen +

  • Jonas Haag

  • Joris Van den Bossche

  • Joshua Shew +

  • Julian Badillo

  • Julian Ortiz +

  • Julien Palard +

  • Justin Tyson +

  • Justus Magin

  • Kabiir Krishna +

  • Kang Su Min

  • Ketu Patel +

  • Kevin +

  • Kevin Anderson

  • Kevin Jan Anker

  • Kevin Klein +

  • Kevin Sheppard

  • Kostya Farber

  • LM +

  • Lars Lien Ankile +

  • Lawrence Mitchell

  • Liwei Cai +

  • Loic Diridollou

  • Luciana Solorzano +

  • Luke Manley

  • Lumberbot(又名 Jack)

  • Marat Kopytjuk +

  • Marc Garcia

  • Marco Edward Gorelli

  • MarcoGorelli

  • Maria Telenczuk +

  • MarvinGravert +

  • Mateusz Sokół +

  • Matt Richards

  • Matthew Barber +

  • Matthew Roeschke

  • Matus Valo +

  • Mia Reimer +

  • Michael Terry +

  • Michael Tiemann +

  • Milad Maani Jou +

  • Miles Cranmer +

  • MirijaH +

  • Miyuu +

  • Natalia Mokeeva

  • Nathan Goldbaum +

  • Nicklaus Roach +

  • Nicolas Camenisch +

  • Nikolay Boev +

  • Nirav

  • Nishu Choudhary

  • Noa Tamir

  • Noy Hanan +

  • Numan +

  • Numan Ijaz +

  • Omar Elbaz +

  • Pandas 开发团队

  • Parfait Gasana

  • Parthi

  • Patrick Hoefler

  • Patrick Schleiter +

  • Pawel Kranzberg +

  • Philip

  • Philip Meier +

  • Pranav Saibhushan Ravuri

  • PrathumP +

  • Rahul Siloniya +

  • Rajasvi Vinayak +

  • Rajat Subhra Mukherjee +

  • Ralf Gommers

  • RaphSku

  • Rebecca Chen +

  • Renato Cotrim Maciel +

  • Reza(Milad)Maanijou +

  • Richard Shadrach

  • Rithik Reddy +

  • Robert Luce +

  • Ronalido +

  • Rylie Wei +

  • SOUMYADIP MAL +

  • Sanjith Chockan +

  • Sayed Qaiser Ali +

  • Scott Harp +

  • Se +

  • Shashwat Agrawal

  • Simar Bassi +

  • Simon Brugman +

  • Simon Hawkins

  • Simon Høxbro Hansen

  • Snorf Yang +

  • Sortofamudkip +

  • Stefan Krawczyk

  • Stefanie Molin

  • Stefanie Senger

  • Stelios Petrakis +

  • Stijn Van Hoey

  • Sven

  • Sylvain MARIE

  • Sylvain Marié

  • Terji Petersen

  • Thierry Moisan

  • Thomas

  • Thomas A Caswell

  • Thomas Grainger

  • Thomas Li

  • Thomas Vranken +

  • Tianye Song +

  • Tim Hoffmann

  • Tim Loderhose +

  • Tim Swast

  • Timon Jurschitsch +

  • Tolker-KU +

  • Tomas Pavlik +

  • Toroi +

  • Torsten Wörtwein

  • Travis Gibbs +

  • Umberto Fasci +

  • Valerii +

  • VanMyHu +

  • Victor Momodu +

  • Vijay Vaidyanathan +

  • VomV +

  • William Andrea

  • William Ayd

  • Wolf Behrenhoff +

  • Xiao Yuan

  • Yao Xiao

  • Yasin Tatar

  • Yaxin Li +

  • Yi Wei +

  • Yulia +

  • Yusharth Singh +

  • Zach Breger +

  • Zhengbo Wang

  • abokey1 +

  • ahmad2901 +

  • assafam +

  • auderson

  • august-tengland +

  • bunardsheng +

  • cmmck +

  • cnguyen-03 +

  • coco +

  • dependabot[bot]

  • giplessis +

  • github-actions[bot]

  • gmaiwald +

  • gmollard +

  • jbrockmendel

  • kathleenhang

  • kevx82 +

  • lia2710 +

  • liang3zy22 +

  • ltartaro +

  • lusolorz +

  • m-ganko +

  • mKlepsch +

  • mattkeanny +

  • mrastgoo +

  • nabdoni +

  • omar-elbaz +

  • paulreece +

  • penelopeysm +

  • potap75 +

  • pre-commit-ci[bot] +

  • raanasn +

  • raj-thapa +

  • ramvikrams +

  • rebecca-palmer

  • reddyrg1 +

  • rmhowe425 +

  • segatrade +

  • shteken +

  • sweisss +

  • taytzehao

  • tntmatthews +

  • tpaxman +

  • tzehaoo +

  • v-mcoutinho +

  • wcgonzal +

  • yonashub

  • yusharth +

  • Ádám Lippai

  • Štěpán Műller + ## 增强功能

PyArrow 将在 pandas 3.0 中成为必需依赖

PyArrow 将成为 pandas 3.0 版本的必需依赖。此决定基于 PDEP 10

这将使得对 pandas 用户极其有益的更多变化成为可能,包括但不限于:

  • 默认情况下将字符串推断为 PyArrow 支持的字符串,从而显著减少内存占用并实现巨大的性能提升。

  • 默认情况下使用 PyArrow 推断更复杂的数据类型,如 Decimallistsbytesstructured data 等。

  • 与依赖于 Apache Arrow 的其他库更好地互操作。

我们正在这里收集对此决定的反馈。 ### 默认情况下避免使用 NumPy 对象数据类型存储字符串

以前,默认情况下,所有字符串都存储在 NumPy 对象 dtype 的列中。此版本引入了一个选项 future.infer_string,该选项将所有字符串推断为 PyArrow 支持的字符串,并且 dtype 为 "string[pyarrow_numpy]"。这是一种新的字符串 dtype 实现,它遵循 NumPy 在比较操作中的语义,并将 np.nan 作为缺失值指示符返回。设置该选项还将推断 dtype "string"StringDtype,存储设置为 "pyarrow_numpy",忽略选项 mode.string_storage 后面的值。

此选项仅在安装了 PyArrow 时有效。PyArrow 支持的字符串具有显着减少的内存占用和与 NumPy 对象相比提供了很大的性能改进(GH 54430)。

可以通过以下方式启用该选项:

pd.options.future.infer_string = True 

这种行为将在 pandas 3.0 中成为默认行为。### DataFrame reductions 保留扩展的 dtypes

在之前的 pandas 版本中,DataFrame reductions(DataFrame.sum() DataFrame.mean() 等)的结果具有 NumPy 的 dtypes,即使 DataFrame 是扩展的 dtypes。现在,当对具有共同 dtype 的 DataFrame 列进行缩减时,Pandas 可以保留 dtypes(GH 52788)。

旧行为

In [1]: df = pd.DataFrame({"a": [1, 1, 2, 1], "b": [np.nan, 2.0, 3.0, 4.0]}, dtype="Int64")
In [2]: df.sum()
Out[2]:
a    5
b    9
dtype: int64
In [3]: df = df.astype("int64[pyarrow]")
In [4]: df.sum()
Out[4]:
a    5
b    9
dtype: int64 

新行为

In [1]: df = pd.DataFrame({"a": [1, 1, 2, 1], "b": [np.nan, 2.0, 3.0, 4.0]}, dtype="Int64")

In [2]: df.sum()
Out[2]: 
a    5
b    9
dtype: Int64

In [3]: df = df.astype("int64[pyarrow]")

In [4]: df.sum()
Out[4]: 
a    5
b    9
dtype: int64[pyarrow] 

注意,dtype 现在分别是掩码 dtype 和 PyArrow dtype,而以前是 NumPy 整数 dtype。

为了允许 DataFrame reductions 保留扩展的 dtypes,ExtensionArray._reduce() 已经得到一个新的关键字参数 keepdims。调用 ExtensionArray._reduce(),带有 keepdims=True 应该返回一个沿着缩减轴长度为 1 的数组。为了保持向后兼容性,该参数不是必需的,但将来可能会变得必需。如果在签名中找不到该参数,则 DataFrame reductions 无法保留扩展的 dtypes。此外,如果未找到参数,将发出 FutureWarning,并且类型检查器如 mypy 可能会抱怨签名与 ExtensionArray._reduce() 不兼容。### 写时复制改进

  • funcSeries 中原地修改时,Series.transform() 不尊重写时复制(GH 53747)。

  • 调用 Index.values() 现在将返回一个只读的 NumPy 数组(GH 53704)。

  • Series设置到DataFrame现在创建惰性副本而不是深层副本 (GH 53142)

  • 当从索引对象字典构造 DataFrame 并指定copy=False时,DataFrame构造函数现在将使用这些索引对象的惰性副本作为 DataFrame 的列(GH 52947

  • 对于 Series 或 DataFrame 的浅层复制(df.copy(deep=False)),现在还将返回行/列的浅层副本 Index对象,而不仅仅是数据的浅层副本,即结果的索引不再相同(df.copy(deep=False).index is df.index 不再为 True)(GH 53721)

  • DataFrame.head()DataFrame.tail() 现在将返回深层副本 (GH 54011)

  • DataFrame.eval() 中添加惰性复制机制 (GH 53746)

  • 当启用写时复制时,尝试在临时列选择上进行就地操作(例如,df["a"].fillna(100, inplace=True))现在将始终引发警告。在这种模式下,像这样就地操作永远不会起作用,因为选择行为像临时副本一样。对以下内容适用:

    • DataFrame.update / Series.update

    • DataFrame.fillna / Series.fillna

    • DataFrame.replace / Series.replace

    • DataFrame.clip / Series.clip

    • DataFrame.where / Series.where

    • DataFrame.mask / Series.mask

    • DataFrame.interpolate / Series.interpolate

    • DataFrame.ffill / Series.ffill

    • DataFrame.bfill / Series.bfill ### 新的 DataFrame.map() 方法和对 ExtensionArrays 的支持

DataFrame.map() 已添加,DataFrame.applymap() 已被弃用。 DataFrame.map() 具有与 DataFrame.applymap() 相同的功能,但新名称更好地传达了这是 Series.map()DataFrame 版本(GH 52353)。

当给定一个可调用对象时,Series.map() 将可调用对象应用于 Series 的所有元素。 类似地,DataFrame.map() 将可调用对象应用于 DataFrame 的所有元素,而 Index.map() 将可调用对象应用于 Index 的所有元素。

经常情况下,不希望将可调用对象应用于数组的类似 nan 的值,为了避免这种情况,可以使用 map 方法调用 na_action="ignore",即 ser.map(func, na_action="ignore")。 然而,na_action="ignore" 没有被实现在许多 ExtensionArrayIndex 类型中,并且 na_action="ignore" 对于除了可空数值类型(即具有 dtype Int64 等)之外的任何 ExtensionArray 子类都不起作用。

na_action="ignore" 现在适用于所有数组类型(GH 52219, GH 51645, GH 51809, GH 51936, GH 52033; GH 52096)。

先前行为

In [1]: ser = pd.Series(["a", "b", np.nan], dtype="category")
In [2]: ser.map(str.upper, na_action="ignore")
NotImplementedError
In [3]: df = pd.DataFrame(ser)
In [4]: df.applymap(str.upper, na_action="ignore")  # worked for DataFrame
 0
0    A
1    B
2  NaN
In [5]: idx = pd.Index(ser)
In [6]: idx.map(str.upper, na_action="ignore")
TypeError: CategoricalIndex.map() got an unexpected keyword argument 'na_action' 

新行为

In [5]: ser = pd.Series(["a", "b", np.nan], dtype="category")

In [6]: ser.map(str.upper, na_action="ignore")
Out[6]: 
0      A
1      B
2    NaN
dtype: category
Categories (2, object): ['A', 'B']

In [7]: df = pd.DataFrame(ser)

In [8]: df.map(str.upper, na_action="ignore")
Out[8]: 
 0
0    A
1    B
2  NaN

In [9]: idx = pd.Index(ser)

In [10]: idx.map(str.upper, na_action="ignore")
Out[10]: CategoricalIndex(['A', 'B', nan], categories=['A', 'B'], ordered=False, dtype='category') 

还要注意,Categorical.map() 默认地将其na_action设置为"ignore"。这已经被弃用,Categorical.map() 的默认值将更改为na_action=None,与所有其他数组类型一致。 ### DataFrame.stack() 的新实现

pandas 已经重新实现了 DataFrame.stack()。要使用新的实现,请传递参数 future_stack=True。这将在 pandas 3.0 中成为唯一的选项。

前一个实现有两个主要的行为缺陷。

  1. 以前的实现会不必要地在结果中引入 NA 值。用户可以通过传递dropna=True(默认值)自动删除 NA 值,但这样做也可能会从输入中删除结果中存在的 NA 值。请参见下面的示例。

  2. 以前的实现中使用了 sort=True(默认值),有时会对结果索引的部分进行排序,有时则不会。如果输入的列 不是 MultiIndex,那么结果索引将永远不会被排序。如果列是 MultiIndex,那么在大多数情况下,来自堆叠列级别的结果索引的级别会被排序。在罕见的情况下,这样的级别将以非标准顺序进行排序,这取决于列的创建方式。

新实现(future_stack=True)在堆叠多个级别时不再会不必要地引入 NA 值,并且永远不会排序。因此,当使用future_stack=True时,参数dropnasort不被使用,并且在使用future_stack=True时必须保持未指定状态。这些参数将在下一个主要版本中被移除。

In [11]: columns = pd.MultiIndex.from_tuples([("B", "d"), ("A", "c")])

In [12]: df = pd.DataFrame([[0, 2], [1, 3]], index=["z", "y"], columns=columns)

In [13]: df
Out[13]: 
 B  A
 d  c
z  0  2
y  1  3 

在以前的版本(future_stack=False)中,默认值dropna=True会删除不必要引入的 NA 值,但仍会在此过程中强制将 dtype 转换为float64。在新版本中,不会引入任何 NA 值,因此不会强制转换 dtype。

In [14]: df.stack([0, 1], future_stack=False, dropna=True)
Out[14]: 
z  A  c    2.0
 B  d    0.0
y  A  c    3.0
 B  d    1.0
dtype: float64

In [15]: df.stack([0, 1], future_stack=True)
Out[15]: 
z  B  d    0
 A  c    2
y  B  d    1
 A  c    3
dtype: int64 

如果输入包含 NA 值,以前的版本会使用dropna=True将其删除,或者使用dropna=False引入新的 NA 值。新版本保留输入中的所有值。

In [16]: df = pd.DataFrame([[0, 2], [np.nan, np.nan]], columns=columns)

In [17]: df
Out[17]: 
 B    A
 d    c
0  0.0  2.0
1  NaN  NaN

In [18]: df.stack([0, 1], future_stack=False, dropna=True)
Out[18]: 
0  A  c    2.0
 B  d    0.0
dtype: float64

In [19]: df.stack([0, 1], future_stack=False, dropna=False)
Out[19]: 
0  A  d    NaN
 c    2.0
 B  d    0.0
 c    NaN
1  A  d    NaN
 c    NaN
 B  d    NaN
 c    NaN
dtype: float64

In [20]: df.stack([0, 1], future_stack=True)
Out[20]: 
0  B  d    0.0
 A  c    2.0
1  B  d    NaN
 A  c    NaN
dtype: float64 
```  ### 其他增强

+   `Series.ffill()` 和 `Series.bfill()` 现在支持具有 `IntervalDtype` 的对象([GH 54247](https://github.com/pandas-dev/pandas/issues/54247))

+   在`read_parquet()`中添加了`filters`参数以过滤数据,与`engines`兼容 ([GH 53212](https://github.com/pandas-dev/pandas/issues/53212))

+   `Categorical.map()`和`CategoricalIndex.map()`现在有一个`na_action`参数。`Categorical.map()`隐式地对`na_action`使用了`"ignore"`的默认值。这已经正式被弃用,并将来会更改为`None`。还请注意,`Series.map()`的默认`na_action=None`,并且对具有分类数据的系列的调用现在将使用`na_action=None`,除非显式设置为其他值 ([GH 44279](https://github.com/pandas-dev/pandas/issues/44279))

+   `api.extensions.ExtensionArray`现在有一个`map()`方法 ([GH 51809](https://github.com/pandas-dev/pandas/issues/51809))

+   `DataFrame.applymap()`现在使用底层`api.extensions.ExtensionArray`实例的`map()`方法 ([GH 52219](https://github.com/pandas-dev/pandas/issues/52219))

+   `MultiIndex.sort_values()`现在支持`na_position` ([GH 51612](https://github.com/pandas-dev/pandas/issues/51612))

+   `MultiIndex.sortlevel()`和`Index.sortlevel()`新增了一个`na_position`关键字 ([GH 51612](https://github.com/pandas-dev/pandas/issues/51612))

+   `arrays.DatetimeArray.map()`、`arrays.TimedeltaArray.map()`和`arrays.PeriodArray.map()`现在可以接受一个`na_action`参数 ([GH 51644](https://github.com/pandas-dev/pandas/issues/51644))

+   `arrays.SparseArray.map()`现在支持`na_action` ([GH 52096](https://github.com/pandas-dev/pandas/issues/52096)).

+   `pandas.read_html()`现在在使用 URL 时支持`storage_options`关键字,允许用户向出站 HTTP 请求添加头部 ([GH 49944](https://github.com/pandas-dev/pandas/issues/49944))

+   添加了`Index.diff()`和`Index.round()` ([GH 19708](https://github.com/pandas-dev/pandas/issues/19708))

+   将`"latex-math"`作为`Styler`的`escape`参数的选项添加,这样在格式化期间将不会转义`"\("`和`"\)"`之间的所有字符 ([GH 51903](https://github.com/pandas-dev/pandas/issues/51903))

+   将类别的 dtype 添加到 `CategoricalDtype` 的 `repr` 信息中 ([GH 52179](https://github.com/pandas-dev/pandas/issues/52179))

+   将 `engine_kwargs` 参数添加到 `read_excel()` 中 ([GH 52214](https://github.com/pandas-dev/pandas/issues/52214))

+   在新的子模块 `pandas.api.typing` 中将用于类型提示的类添加到公共 API 中 ([GH 48577](https://github.com/pandas-dev/pandas/issues/48577))

+   实现了`Series.dt.is_month_start`,`Series.dt.is_month_end`,`Series.dt.is_year_start`,`Series.dt.is_year_end`,`Series.dt.is_quarter_start`,`Series.dt.is_quarter_end`,`Series.dt.days_in_month`,`Series.dt.unit`,`Series.dt.normalize`,`Series.dt.day_name()`,`Series.dt.month_name()`,`Series.dt.tz_convert()`,用于 `ArrowDtype` 的 `pyarrow.timestamp` ([GH 52388](https://github.com/pandas-dev/pandas/issues/52388), [GH 51718](https://github.com/pandas-dev/pandas/issues/51718))

+   `DataFrameGroupBy.agg()` 和 `DataFrameGroupBy.transform()` 现在在索引不是 `MultiIndex` 时支持按多个键分组,`engine="numba"`([GH 53486](https://github.com/pandas-dev/pandas/issues/53486))

+   `SeriesGroupBy.agg()` 和 `DataFrameGroupBy.agg()` 现在支持将多个函数传入 `engine="numba"`([GH 53486](https://github.com/pandas-dev/pandas/issues/53486))

+   `SeriesGroupBy.transform()` 和 `DataFrameGroupBy.transform()` 现在支持将字符串作为 `engine="numba"` 的函数传入([GH 53579](https://github.com/pandas-dev/pandas/issues/53579))

+   `DataFrame.stack()` 新增了 `sort` 参数,用于指定结果的 `MultiIndex` 索引是否排序([GH 15105](https://github.com/pandas-dev/pandas/issues/15105))

+   `DataFrame.unstack()` 新增了 `sort` 参数,用于指定结果的 `MultiIndex` 索引是否排序([GH 15105](https://github.com/pandas-dev/pandas/issues/15105))

+   `Series.explode()` 现在支持 PyArrow 支持的列表类型([GH 53602](https://github.com/pandas-dev/pandas/issues/53602))

+   `Series.str.join()` 现在支持 `ArrowDtype(pa.string())`([GH 53646](https://github.com/pandas-dev/pandas/issues/53646))

+   在 `Categorical.from_codes()` 中添加了 `validate` 参数([GH 50975](https://github.com/pandas-dev/pandas/issues/50975))

+   添加了`ExtensionArray.interpolate()`,被`Series.interpolate()`和`DataFrame.interpolate()`使用([GH 53659](https://github.com/pandas-dev/pandas/issues/53659))

+   向`DataFrame.to_excel()`添加了`engine_kwargs`参数([GH 53220](https://github.com/pandas-dev/pandas/issues/53220))

+   实现了`api.interchange.from_dataframe()`用于`DatetimeTZDtype`([GH 54239](https://github.com/pandas-dev/pandas/issues/54239))

+   在`DatetimeTZDtype`上实现了`__from_arrow__`([GH 52201](https://github.com/pandas-dev/pandas/issues/52201))

+   实现了`__pandas_priority__`,允许自定义类型优先于`DataFrame`、`Series`、`Index`或`ExtensionArray`进行算术运算,请参阅开发人员指南([GH 48347](https://github.com/pandas-dev/pandas/issues/48347))

+   当使用`DataFrame.merge()`时,改进了具有不兼容列时的错误消息([GH 51861](https://github.com/pandas-dev/pandas/issues/51861))

+   通过`DataFrame.isetitem()`在设置`DataFrame`时,当列数错误时改进错误消息([GH 51701](https://github.com/pandas-dev/pandas/issues/51701))

+   在使用`DataFrame.to_json()`时,改进了处理���兼容`index`和`orient`参数时的错误处理([GH 52143](https://github.com/pandas-dev/pandas/issues/52143))

+   在创建具有空数据(0 行)、无索引和不正确列数的 DataFrame 时,改进了错误消息([GH 52084](https://github.com/pandas-dev/pandas/issues/52084))

+   当向`VariableOffsetWindowIndexer`)

+   允许`DataFrame.to_feather()`和非字符串列名([GH 51787](https://github.com/pandas-dev/pandas/issues/51787))

+   向`Series.apply()``](../reference/api/pandas.DataFrame.apply.html#pandas.DataFrame.apply "pandas.DataFrame.apply")添加了一个新参数`by_row`。当设置为`False`时,提供的可调用对象将始终对整个 Series 或 DataFrame 进行操作([GH 53400](https://github.com/pandas-dev/pandas/issues/53400),[GH 53601](https://github.com/pandas-dev/pandas/issues/53601))

+   `DataFrame.shift()``](../reference/api/pandas.Series.shift.html#pandas.Series.shift "pandas.Series.shift")现在允许通过提供一系列周期来进行多周期的偏移([GH 44424](https://github.com/pandas-dev/pandas/issues/44424))

+   使用`numba`进行分组聚合(如`DataFrameGroupBy.sum()`)

+   当`DataFrameGroupBy.agg()`)

+   许多读取/写入函数,如`DataFrame.to_pickle()``](../reference/api/pandas.read_csv.html#pandas.read_csv "pandas.read_csv"),支持将压缩参数转发给`lzma.LZMAFile`([GH 52979](https://github.com/pandas-dev/pandas/issues/52979))

+   缩减函数 `Series.argmax()`、`Series.argmin()`、`Series.idxmax()`、`Series.idxmin()`、`Index.argmax()`、`Index.argmin()`、`DataFrame.idxmax()`、`DataFrame.idxmin()` 现在支持对象数据类型([GH 4279](https://github.com/pandas-dev/pandas/issues/4279),[GH 18021](https://github.com/pandas-dev/pandas/issues/18021),[GH 40685](https://github.com/pandas-dev/pandas/issues/40685),[GH 43697](https://github.com/pandas-dev/pandas/issues/43697))

+   `DataFrame.to_parquet()` 和 `read_parquet()` 现在分别写入和读取 `attrs`([GH 54346](https://github.com/pandas-dev/pandas/issues/54346))

+   `Index.all()` 和 `Index.any()` 在浮点数据类型和 timedelta64 数据类型中不再引发 `TypeError`,与 `Series.all()` 和 `Series.any()` 的行为相匹配([GH 54566](https://github.com/pandas-dev/pandas/issues/54566))

+   `Series.cummax()`、`Series.cummin()` 和 `Series.cumprod()` 现在支持 pyarrow 版本 13.0 及以上的数据类型([GH 52085](https://github.com/pandas-dev/pandas/issues/52085))

+   增加对 DataFrame Consortium Standard 的支持([GH 54383](https://github.com/pandas-dev/pandas/issues/54383))

+   在`DataFrameGroupBy.quantile()`和`SeriesGroupBy.quantile()`中的性能改进([GH 51722](https://github.com/pandas-dev/pandas/issues/51722))。

+   PyArrow 支持的整数数据类型现在支持位操作([GH 54495](https://github.com/pandas-dev/pandas/issues/54495))### PyArrow 将成为 pandas 3.0 的必需依赖项

[PyArrow](https://arrow.apache.org/docs/python/index.html)将从 pandas 3.0 开始成为 pandas 的必需依赖项。这一决定是基于[PDEP 10](https://pandas.pydata.org/pdeps/0010-required-pyarrow-dependency.html)。

这将使得更多对 pandas 用户极其有益的更改成为可能,包括但不限于:

+   默认情况下将字符串推断为 PyArrow 支持的字符串,从而显著减少内存占用并实现巨大的性能改进。

+   默认情况下,使用 PyArrow 推断更复杂的数据类型,如`Decimal`、`lists`、`bytes`、`structured data`等。

+   与依赖于 Apache Arrow 的其他库更好地实现互操作性。

我们正在[此处](https://github.com/pandas-dev/pandas/issues/54466)收集有关此决定的反馈。

### 默认情况下避免使用 NumPy 对象数据类型存储字符串

以前,默认情况下,所有字符串都存储在具有 NumPy 对象数据类型的列中。此版本引入了一个选项`future.infer_string`,将所有字符串推断为 PyArrow 支持的字符串,数据类型为`"string[pyarrow_numpy]"`。这是一种遵循 NumPy 语义的新字符串数据类型实现,在比较操作中将返回`np.nan`作为缺失值指示符。设置该选项还将推断数据类型`"string"`为`StringDtype`,存储设置为`"pyarrow_numpy"`,忽略选项`mode.string_storage`后面的值。

仅当安装了 PyArrow 时,此选项才有效。PyArrow 支持的字符串具有显著减少的内存占用,并与 NumPy 对象相比提供了很大的性能改进([GH 54430](https://github.com/pandas-dev/pandas/issues/54430))。

可以通过以下方式启用该选项:

```py
pd.options.future.infer_string = True 

这种行为将成为 pandas 3.0 的默认设置。

DataFrame reductions 保留扩展数据类型

在 pandas 的早期版本中,DataFrame 缩减的结果(DataFrame.sum() DataFrame.mean() 等)即使 DataFrame 是扩展数据类型,也具有 NumPy 数据类型。现在,当对具有共同数据类型的 DataFrame 列进行缩减时,Pandas 可以保留数据类型(GH 52788)。

旧行为

In [1]: df = pd.DataFrame({"a": [1, 1, 2, 1], "b": [np.nan, 2.0, 3.0, 4.0]}, dtype="Int64")
In [2]: df.sum()
Out[2]:
a    5
b    9
dtype: int64
In [3]: df = df.astype("int64[pyarrow]")
In [4]: df.sum()
Out[4]:
a    5
b    9
dtype: int64 

新行为

In [1]: df = pd.DataFrame({"a": [1, 1, 2, 1], "b": [np.nan, 2.0, 3.0, 4.0]}, dtype="Int64")

In [2]: df.sum()
Out[2]: 
a    5
b    9
dtype: Int64

In [3]: df = df.astype("int64[pyarrow]")

In [4]: df.sum()
Out[4]: 
a    5
b    9
dtype: int64[pyarrow] 

注意现在 dtype 分别是遮罩 dtype 和 PyArrow dtype,而以前是 NumPy 整数 dtype。

为了允许 DataFrame 的缩减保留扩展的数据类型,ExtensionArray._reduce() 添加了一个新的关键字参数 keepdims。调用带有 keepdims=TrueExtensionArray._reduce() 应该返回沿着缩减轴长度为 1 的数组。为了保持向后兼容性,该参数不是必需的,但将来可能会变成必需的。如果在签名中找不到该参数,则 DataFrame 的缩减将无法保留扩展的数据类型。此外,如果找不到该参数,将发出 FutureWarning,并且像 mypy 这样的类型检查器可能会抱怨签名与 ExtensionArray._reduce() 不兼容。

Copy-on-Write 改进

  • func 原地修改 Series 时,Series.transform() 不尊重 Copy-on-Write(GH 53747

  • 调用 Index.values() 现在将返回一个只读的 NumPy 数组(GH 53704)。

  • 将一个 Series 设置到一个 DataFrame 现在创建一个惰性副本而不是深度副本(GH 53142)。

  • 当使用字典的 Index 对象构造 DataFrame 并指定 copy=False 时,DataFrame 构造函数现在将使用这些 Index 对象的惰性拷贝作为 DataFrame 的列 (GH 52947)

  • 对 Series 或 DataFrame 的浅拷贝 (df.copy(deep=False)) 现在还将返回行/列的浅拷贝 Index 对象而不仅仅是数据的浅拷贝,即结果的索引不再相同(df.copy(deep=False).index is df.index 不再为 True) (GH 53721)

  • DataFrame.head()DataFrame.tail() 现在将返回深拷贝(GH 54011

  • DataFrame.eval() 添加惰性拷贝机制 (GH 53746)

  • 在临时列选择上尝试原地操作(例如,df["a"].fillna(100, inplace=True))现在在启用写时复制时始终会引发警告。在这种模式下,像这样原地操作永远不会起作用,因为选择行为像一个临时副本。这对以下情况成立:

    • DataFrame.update / Series.update

    • DataFrame.fillna / Series.fillna

    • DataFrame.replace / Series.replace

    • DataFrame.clip / Series.clip

    • DataFrame.where / Series.where

    • DataFrame.mask / Series.mask

    • DataFrame.interpolate / Series.interpolate

    • DataFrame.ffill / Series.ffill

    • DataFrame.bfill / Series.bfill

新的 DataFrame.map() 方法和对 ExtensionArrays 的支持

已添加 DataFrame.map() 并且已弃用 DataFrame.applymap()DataFrame.map() 具有与 DataFrame.applymap() 相同的功能,但新名称更好地传达了这是 DataFrame 版本的 Series.map() (GH 52353)。

给定一个 callable,Series.map() 将 callable 应用于 Series 的所有元素。类似地,DataFrame.map() 将 callable 应用于 DataFrame 的所有元素,而 Index.map() 将 callable 应用于 Index 的所有元素。

经常情况下,不希望将 callable 应用于数组的类似 nan 的值,为了避免这样做,可以使用 map 方法调用 na_action="ignore",即 ser.map(func, na_action="ignore")。然而,na_action="ignore" 并未为许多 ExtensionArrayIndex 类型实现,na_action="ignore" 对于任何 ExtensionArray 子类都不起作用,除了可空的数值类型(即具有 dtype Int64 等)。

现在 na_action="ignore" 对所有数组类型都起作用 (GH 52219, GH 51645, GH 51809, GH 51936, GH 52033; GH 52096)。

之前的行为

In [1]: ser = pd.Series(["a", "b", np.nan], dtype="category")
In [2]: ser.map(str.upper, na_action="ignore")
NotImplementedError
In [3]: df = pd.DataFrame(ser)
In [4]: df.applymap(str.upper, na_action="ignore")  # worked for DataFrame
 0
0    A
1    B
2  NaN
In [5]: idx = pd.Index(ser)
In [6]: idx.map(str.upper, na_action="ignore")
TypeError: CategoricalIndex.map() got an unexpected keyword argument 'na_action' 

新的行为

In [5]: ser = pd.Series(["a", "b", np.nan], dtype="category")

In [6]: ser.map(str.upper, na_action="ignore")
Out[6]: 
0      A
1      B
2    NaN
dtype: category
Categories (2, object): ['A', 'B']

In [7]: df = pd.DataFrame(ser)

In [8]: df.map(str.upper, na_action="ignore")
Out[8]: 
 0
0    A
1    B
2  NaN

In [9]: idx = pd.Index(ser)

In [10]: idx.map(str.upper, na_action="ignore")
Out[10]: CategoricalIndex(['A', 'B', nan], categories=['A', 'B'], ordered=False, dtype='category') 

此外,注意 Categorical.map() 默认情况下隐式地将其 na_action 设置为 "ignore"。这已被弃用,Categorical.map() 的默认值将更改为 na_action=None,与所有其他数组类型保持一致。

DataFrame.stack() 的新实现

pandas 已重新实现了 DataFrame.stack()。要使用新实现,传递参数 future_stack=True。这将成为 pandas 3.0 中的唯一选项。

之前的实现有两个主要的行为缺点。

  1. 之前的实现会在结果中不必要地引入 NA 值。用户可以通过传递 dropna=True(默认值)自动删除 NA 值,但这样做也可能从输入中删除结果中存在的 NA 值。请参见下面的示例。

  2. 具有sort=True(默认)的先前实现有时会对结果索引的一部分进行排序,有时则不会。如果输入的列不是 MultiIndex,那么结果索引永远不会被排序。如果列是 MultiIndex,那么在大多数情况下,来自堆叠列级别的结果索引的级别会被排序。在罕见情况下,这样的级别会按非标准顺序排序,这取决于列是如何创建的。

新实现(future_stack=True)在堆叠多个级别时将不再不必要地引入 NA 值,并且永远不会排序。因此,在使用 future_stack=True 时,不使用参数 dropnasort,必须保持未指定。这些参数将在下一个主要版本中被移除。

In [11]: columns = pd.MultiIndex.from_tuples([("B", "d"), ("A", "c")])

In [12]: df = pd.DataFrame([[0, 2], [1, 3]], index=["z", "y"], columns=columns)

In [13]: df
Out[13]: 
 B  A
 d  c
z  0  2
y  1  3 

在先前版本中(future_stack=False),dropna=True 的默认值会删除不必要引入的 NA 值,但仍会在过程中强制将 dtype 转换为 float64。在新版本中,不会引入任何 NA 值,因此不会强制转换 dtype。

In [14]: df.stack([0, 1], future_stack=False, dropna=True)
Out[14]: 
z  A  c    2.0
 B  d    0.0
y  A  c    3.0
 B  d    1.0
dtype: float64

In [15]: df.stack([0, 1], future_stack=True)
Out[15]: 
z  B  d    0
 A  c    2
y  B  d    1
 A  c    3
dtype: int64 

如果输入包含 NA 值,先前版本会使用 dropna=True 删除这些值,或者使用 dropna=False 引入新的 NA 值。新版本将保留来自输入的所有值。

In [16]: df = pd.DataFrame([[0, 2], [np.nan, np.nan]], columns=columns)

In [17]: df
Out[17]: 
 B    A
 d    c
0  0.0  2.0
1  NaN  NaN

In [18]: df.stack([0, 1], future_stack=False, dropna=True)
Out[18]: 
0  A  c    2.0
 B  d    0.0
dtype: float64

In [19]: df.stack([0, 1], future_stack=False, dropna=False)
Out[19]: 
0  A  d    NaN
 c    2.0
 B  d    0.0
 c    NaN
1  A  d    NaN
 c    NaN
 B  d    NaN
 c    NaN
dtype: float64

In [20]: df.stack([0, 1], future_stack=True)
Out[20]: 
0  B  d    0.0
 A  c    2.0
1  B  d    NaN
 A  c    NaN
dtype: float64 

其他增强

  • Series.ffill()Series.bfill() 现在支持具有 IntervalDtype 的对象(GH 54247

  • read_parquet() 添加了 filters 参数以过滤数据,与两种 engines 兼容(GH 53212

  • Categorical.map()CategoricalIndex.map() 现在具有 na_action 参数。Categorical.map() 对于 na_action 隐式地具有默认值 "ignore"。这已正式被弃用,并将在未来更改为 None。还要注意,Series.map() 的默认 na_action=None,对具有分类数据的系列的调用现在将使用 na_action=None,除非另有明确设置(GH 44279

  • api.extensions.ExtensionArray现在有一个map()方法(GH 51809

  • DataFrame.applymap()现在使用底层api.extensions.ExtensionArray实例的map()方法(GH 52219

  • MultiIndex.sort_values()现在支持na_positionGH 51612

  • MultiIndex.sortlevel()Index.sortlevel()增加了一个新的关键字na_positionGH 51612

  • arrays.DatetimeArray.map()arrays.TimedeltaArray.map()arrays.PeriodArray.map()现在可以接受na_action参数(GH 51644

  • arrays.SparseArray.map()现在支持na_actionGH 52096

  • 当与 URL 一起使用时,pandas.read_html()现在支持storage_options关键字,允许用户向出站 HTTP 请求添加标头(GH 49944

  • 添加了Index.diff()Index.round()GH 19708

  • "latex-math"添加为Stylerescape参数的选项,这样在格式化期间不会转义"\(""\)"之间的所有字符(GH 51903

  • 将类别的 dtype 添加到CategoricalDtyperepr信息中(GH 52179

  • read_excel()添加了engine_kwargs参数(GH 52214

  • 在新的子模块pandas.api.typing中向公共 API 添加了用于类型提示的类(GH 48577

  • 实现了 Series.dt.is_month_start, Series.dt.is_month_end, Series.dt.is_year_start, Series.dt.is_year_end, Series.dt.is_quarter_start, Series.dt.is_quarter_end, Series.dt.days_in_month, Series.dt.unit, Series.dt.normalize, Series.dt.day_name(), Series.dt.month_name(), Series.dt.tz_convert() 用于带有 pyarrow.timestampArrowDtype (GH 52388, GH 51718)

  • DataFrameGroupBy.agg()DataFrameGroupBy.transform() 现在在索引不是 MultiIndex 的情况下支持按多个键分组,用于 engine="numba" (GH 53486)

  • SeriesGroupBy.agg()DataFrameGroupBy.agg() 现在支持传入多个函数以供 engine="numba" 使用(GH 53486

  • SeriesGroupBy.transform()DataFrameGroupBy.transform() 现在支持传入字符串作为 engine="numba" 的函数(GH 53579

  • DataFrame.stack() 添加了 sort 关键字,用于指定生成的 MultiIndex 索引级别是否排序(GH 15105

  • DataFrame.unstack() 添加了 sort 关键字,用于指定生成的 MultiIndex 索引级别是否排序(GH 15105

  • Series.explode() 现在支持 PyArrow 支持的列表类型(GH 53602

  • Series.str.join() 现在支持 ArrowDtype(pa.string())GH 53646

  • Categorical.from_codes() 中添加了 validate 参数(GH 50975

  • 添加了 ExtensionArray.interpolate(),可供 Series.interpolate()DataFrame.interpolate() 使用(GH 53659

  • DataFrame.to_excel()中添加了engine_kwargs参数(GH 53220

  • DatetimeTZDtype实现了api.interchange.from_dataframe()GH 54239

  • DatetimeTZDtype上实现了__from_arrow__GH 52201

  • 实现了__pandas_priority__,允许自定义类型优先于DataFrameSeriesIndexExtensionArray进行算术操作,请参阅开发者指南(GH 48347")

  • 在使用DataFrame.merge()时,当有不兼容的列时改进了错误消息(GH 51861

  • 在通过DataFrame.isetitem()设置具有错误列数的DataFrame时改进了错误消息(GH 51701

  • 在使用DataFrame.to_json()时改进了错误处理,当indexorient参数不兼容时(GH 52143

  • 在创建包含空数据(0 行)、没有索引和不正确列数的 DataFrame 时改进了错误消息(GH 52084

  • 在提供无效的indexoffset参数给VariableOffsetWindowIndexer时改进了错误消息(GH 54379

  • DataFrame.to_feather() 接受非默认 Index 和非字符串列名 (GH 51787)

  • Series.apply()DataFrame.apply() 添加了一个新参数 by_row。当设置为 False 时,提供的可调用对象将始终作用于整个 Series 或 DataFrame (GH 53400, GH 53601).

  • DataFrame.shift()Series.shift() 现在允许通过提供周期列表进行多周期移位 (GH 44424)

  • 通过 numba 进行分组聚合(例如 DataFrameGroupBy.sum())现在可以保留输入的数据类型,而不是强制转换为 float64 (GH 44952)

  • DataFrameGroupBy.agg() 失败时,改进了错误消息 (GH 52930)

  • 许多读取/写入函数,如 DataFrame.to_pickle()read_csv(),支持将压缩参数转发给 lzma.LZMAFile (GH 52979)

  • Reductions Series.argmax(), Series.argmin(), Series.idxmax(), Series.idxmin(), Index.argmax(), Index.argmin(), DataFrame.idxmax(), DataFrame.idxmin() 现在支持对象数据类型 (GH 4279, GH 18021, GH 40685, GH 43697)

  • DataFrame.to_parquet()read_parquet() 现在分别会写入和读取 attrs (GH 54346)

  • Index.all()Index.any() 在浮点数据类型和 timedelta64 数据类型上不再引发 TypeError,与 Series.all()Series.any() 的行为一致 (GH 54566)

  • Series.cummax(), Series.cummin()Series.cumprod() 现在支持 pyarrow 数据类型,要求 pyarrow 版本为 13.0 及以上 (GH 52085)

  • 增加了对 DataFrame Consortium Standard 的支持 (GH 54383)

  • DataFrameGroupBy.quantile()SeriesGroupBy.quantile() 的性能改进 (GH 51722)

  • PyArrow 支持的整数 dtype 现在支持按位操作 (GH 54495)

不兼容的后向 API 更改

增加 Python 的最低版本

pandas 2.1.0 支持 Python 3.9 及更高版本。

增加了依赖项的最低版本

一些依赖项的最低支持版本已更新。如果已安装,现在我们需要:

最低版本 所需 更改
numpy 1.22.4 X X
mypy (dev) 1.4.1 X
beautifulsoup4 4.11.1 X
bottleneck 1.3.4 X
dataframe-api-compat 0.1.7 X
fastparquet 0.8.1 X
fsspec 2022.05.0 X
假设 6.46.1 X
gcsfs 2022.05.0 X
jinja2 3.1.2 X
lxml 4.8.0 X
numba 0.55.2 X
numexpr 2.8.0 X
openpyxl 3.0.10 X
pandas-gbq 0.17.5 X
psycopg2 2.9.3 X
pyreadstat 1.1.5 X
pyqt5 5.15.6 X
pytables 3.7.0 X
pytest 7.3.2 X
python-snappy 0.6.1 X
pyxlsb 1.0.9 X
s3fs 2022.05.0 X
scipy 1.8.1 X
sqlalchemy 1.4.36 X
tabulate 0.8.10 X
xarray 2022.03.0 X
xlsxwriter 3.0.3 X
zstandard 0.17.0 X

对于 可选库,一般建议使用最新版本。

有关更多信息,请参见 Dependencies 和 Optional dependencies。

其他 API 更改

  • arrays.PandasArray 已重命名为 NumpyExtensionArray,附带的 dtype 名称从 PandasDtype 更改为 NumpyEADtype;导入 PandasArray 仍然有效,直到下一个主要版本 (GH 53694) ### 增加 Python 的最低版本

pandas 2.1.0 支持 Python 3.9 及更高版本。

增加了依赖项的最低版本

一些依赖项的最低支持版本已更新。如果已安装,现在我们需要:

最低版本 所需 更改
numpy 1.22.4 X X
mypy (dev) 1.4.1 X
beautifulsoup4 4.11.1 X
bottleneck 1.3.4 X
dataframe-api-compat 0.1.7 X
fastparquet 0.8.1 X
fsspec 2022.05.0 X
hypothesis 6.46.1 X
gcsfs 2022.05.0 X
jinja2 3.1.2 X
lxml 4.8.0 X
numba 0.55.2 X
numexpr 2.8.0 X
openpyxl 3.0.10 X
pandas-gbq 0.17.5 X
psycopg2 2.9.3 X
pyreadstat 1.1.5 X
pyqt5 5.15.6 X
pytables 3.7.0 X
pytest 7.3.2 X
python-snappy 0.6.1 X
pyxlsb 1.0.9 X
s3fs 2022.05.0 X
scipy 1.8.1 X
sqlalchemy 1.4.36 X
tabulate 0.8.10 X
xarray 2022.03.0 X
xlsxwriter 3.0.3 X
zstandard 0.17.0 X

对于可选库,一般建议使用最新版本。

有关更多信息,请参阅 Dependencies 和 Optional dependencies。

其他 API 更改

  • arrays.PandasArray已更名为NumpyExtensionArray,附加的数据类型名称从PandasDtype更改为NumpyEADtype;导入PandasArray仍然有效,直到下一个主要版本(GH 53694)

弃用

弃用了类似于 setitem 的 Series 操作中的静默转换

PDEP-6: pandas.pydata.org/pdeps/0006-ban-upcasting.html

对 Series(或 DataFrame 列)进行类似于 setitem 的操作,静默转换数据类型已被弃用并显示警告。受影响操作的示例包括:

  • ser.fillna('foo', inplace=True)

  • ser.where(ser.isna(), 'foo', inplace=True)

  • ser.iloc[indexer] = 'foo'

  • ser.loc[indexer] = 'foo'

  • df.iloc[indexer, 0] = 'foo'

  • df.loc[indexer, 'a'] = 'foo'

  • ser[indexer] = 'foo'

ser 是一个Seriesdf 是一个DataFrame,而indexer可以是一个切片、掩码、单个值、值列表或数组,或任何其他允许的索引器。

在将来的版本中,这些操作将引发错误,您应该首先将其转换为一个公共数据类型。

先前的行为:

In [1]: ser = pd.Series([1, 2, 3])

In [2]: ser
Out[2]:
0    1
1    2
2    3
dtype: int64

In [3]: ser[0] = 'not an int64'

In [4]: ser
Out[4]:
0    not an int64
1               2
2               3
dtype: object 

新行为:

In [1]: ser = pd.Series([1, 2, 3])

In [2]: ser
Out[2]:
0    1
1    2
2    3
dtype: int64

In [3]: ser[0] = 'not an int64'
FutureWarning:
 Setting an item of incompatible dtype is deprecated and will raise an error in a future version of pandas.
 Value 'not an int64' has dtype incompatible with int64, please explicitly cast to a compatible dtype first.

In [4]: ser
Out[4]:
0    not an int64
1               2
2               3
dtype: object 

为了保持当前行为,在上述情况下,您可以首先将ser转换为object数据类型:

In [21]: ser = pd.Series([1, 2, 3])

In [22]: ser = ser.astype('object')

In [23]: ser[0] = 'not an int64'

In [24]: ser
Out[24]: 
0    not an int64
1               2
2               3
dtype: object 

根据用例,将转换为不同的数据类型可能更合适。例如,在以下情况下,我们转换为float64

In [25]: ser = pd.Series([1, 2, 3])

In [26]: ser = ser.astype('float64')

In [27]: ser[0] = 1.1

In [28]: ser
Out[28]: 
0    1.1
1    2.0
2    3.0
dtype: float64 

欲了解更多,请参阅pandas.pydata.org/pdeps/0006-ban-upcasting.html

弃用了解析带有混合时区的日期时间

解析带有混合时区的日期时间已被弃用,并在用户未传递utc=Trueto_datetime()时显示警告(GH 50887

先前的行为

In [7]: data = ["2020-01-01 00:00:00+06:00", "2020-01-01 00:00:00+01:00"]

In [8]:  pd.to_datetime(data, utc=False)
Out[8]:
Index([2020-01-01 00:00:00+06:00, 2020-01-01 00:00:00+01:00], dtype='object') 

新行为

In [9]: pd.to_datetime(data, utc=False)
FutureWarning:
 In a future version of pandas, parsing datetimes with mixed time zones will raise
 a warning unless `utc=True`. Please specify `utc=True` to opt in to the new behaviour
 and silence this warning. To create a `Series` with mixed offsets and `object` dtype,
 please use `apply` and `datetime.datetime.strptime`.
Index([2020-01-01 00:00:00+06:00, 2020-01-01 00:00:00+01:00], dtype='object') 

为了消除此警告并避免在未来版本的 pandas 中出现错误,请指定utc=True

In [29]: data = ["2020-01-01 00:00:00+06:00", "2020-01-01 00:00:00+01:00"]

In [30]: pd.to_datetime(data, utc=True)
Out[30]: DatetimeIndex(['2019-12-31 18:00:00+00:00', '2019-12-31 23:00:00+00:00'], dtype='datetime64[ns, UTC]', freq=None) 

要创建一个具有混合偏移和object dtype 的Series,请使用applydatetime.datetime.strptime

In [31]: import datetime as dt

In [32]: data = ["2020-01-01 00:00:00+06:00", "2020-01-01 00:00:00+01:00"]

In [33]: pd.Series(data).apply(lambda x: dt.datetime.strptime(x, '%Y-%m-%d %H:%M:%S%z'))
Out[33]: 
0    2020-01-01 00:00:00+06:00
1    2020-01-01 00:00:00+01:00
dtype: object 

其他弃用

  • 弃用DataFrameGroupBy.dtypes,请在底层对象上检查dtypes而不是dtypesGH 51045

  • 弃用DataFrame._dataSeries._data,请改用公共 API(GH 33333

  • 当要连接的任何对象的长度为 0 时,弃用concat()行为;在过去,当确定结果 dtype 时,空对象的 dtypes 被忽略,但在将来的版本中将不再忽略(GH 39122

  • 弃用Categorical.to_list(),请改用obj.tolist()GH 51254

  • 弃用带有 datetime64 或PeriodDtype值的DataFrameGroupBy.all()DataFrameGroupBy.any(),匹配SeriesDataFrame的弃用(GH 34479

  • 弃用DataFrame.ewm()DataFrame.rolling()DataFrame.expanding()中的axis=1,在调用方法之前转置(GH 51778

  • 弃用DataFrame.groupby()Grouper构造函数中的axis=1,请改用frame.T.groupby(...)GH 51203

  • Series.align()DataFrame.align()中弃用了broadcast_axis关键字,在调用align之前需使用left = DataFrame({col: left for col in right.columns}, index=right.index)进行类型转换 (GH 51856)

  • Index.fillna()中弃用了downcast关键字 (GH 53956)

  • DataFrame.pct_change()Series.pct_change()DataFrameGroupBy.pct_change()SeriesGroupBy.pct_change()中弃用了fill_methodlimit关键字,需要在调用pct_change之前显式调用例如DataFrame.ffill()DataFrame.bfill() (GH 53491)

  • DataFrame.align()Series.align()中弃用了methodlimitfill_axis关键字,在对齐结果上显式调用DataFrame.fillna()Series.fillna() (GH 51856)

  • Rolling.quantile()Expanding.quantile()中弃用了quantile关键字,改为q (GH 52550)

  • Deprecated accepting slices in DataFrame.take(), call obj[slicer] or pass a sequence of integers instead (GH 51539)

  • Deprecated behavior of DataFrame.idxmax(), DataFrame.idxmin(), Series.idxmax(), Series.idxmin() in with all-NA entries or any-NA and skipna=False; in a future version these will raise ValueError (GH 51276)

  • Deprecated explicit support for subclassing Index (GH 45289)

  • Deprecated making functions given to Series.agg() attempt to operate on each element in the Series and only operate on the whole Series if the elementwise operations failed. In the future, functions given to Series.agg() will always operate on the whole Series only. To keep the current behavior, use Series.transform() instead (GH 53325)

  • Deprecated making the functions in a list of functions given to DataFrame.agg() attempt to operate on each element in the DataFrame and only operate on the columns of the DataFrame if the elementwise operations failed. To keep the current behavior, use DataFrame.transform() instead (GH 53325)

  • 弃用了将DataFrame 传递给DataFrame.from_records() 方法,而应使用 DataFrame.set_index()DataFrame.drop() 方法(GH 51353)。

  • 在将字符串解析为日期时间时,静默弃用了未识别的时区(GH 18702)。

  • DataFrame.ewm()Series.ewm()DataFrame.rolling()Series.rolling()DataFrame.expanding()Series.expanding() 方法中弃用了 axis 关键字(GH 51778)。

  • DataFrame.resample()Series.resample() 方法中弃用了 axis 关键字(GH 51778)。

  • Series.interpolate()DataFrame.interpolate()Series.fillna()DataFrame.fillna()Series.ffill()DataFrame.ffill()Series.bfill()DataFrame.bfill() 方法中弃用了 downcast 关键字(GH 40988)。

  • 弃用了在concat()len(keys) != len(objs) 的行为,在未来的版本中,这将引发而不是截断为两个序列中较短的一个(GH 43485

  • 在存在 NA 值时弃用了Series.argsort() 的行为;在未来的版本中,这些值将被放置在末尾而不是给出 -1(GH 54219

  • 弃用了DataFrame.groupby()Series.groupby()observed=False 的默认值;这将在未来的版本中默认为 TrueGH 43999

  • SeriesGroupBy.aggregate() 聚合中弃用了将 group.name 锁定到每个组的行为;如果您的操作需要使用 groupby 键,请遍历 groupby 对象而不是每个组(GH 41090

  • DataFrameGroupBy.idxmax()DataFrameGroupBy.idxmin()DataFrameGroupBy.fillna()DataFrameGroupBy.take()DataFrameGroupBy.skew()DataFrameGroupBy.rank()DataFrameGroupBy.cumprod()DataFrameGroupBy.cumsum()DataFrameGroupBy.cummax()DataFrameGroupBy.cummin()DataFrameGroupBy.pct_change()DataFrameGroupBy.diff()DataFrameGroupBy.shift()DataFrameGroupBy.corrwith()中弃用了axis关键字;对于axis=1,操作的是底层的DataFrame而不是分组数据(GH 50405GH 51046)

  • 废弃了带有as_index=FalseDataFrameGroupBy,当它们不是 DataFrame 的列时,不包括分组在结果中(GH 49519

  • 废弃了is_categorical_dtype(),请使用isinstance(obj.dtype, pd.CategoricalDtype)代替(GH 52527

  • 废弃了is_datetime64tz_dtype(),请检查isinstance(dtype, pd.DatetimeTZDtype)代替(GH 52607

  • 废弃了is_int64_dtype(),请检查dtype == np.dtype(np.int64)代替(GH 52564

  • 废弃了is_interval_dtype(),请检查isinstance(dtype, pd.IntervalDtype)代替(GH 52607

  • 废弃了is_period_dtype(),请检查isinstance(dtype, pd.PeriodDtype)代替(GH 52642

  • 废弃了is_sparse(),请检查isinstance(dtype, pd.SparseDtype)代替(GH 52642

  • 废弃了Styler.applymap_index()。请使用新的Styler.map_index()方法代替(GH 52708

  • 废弃了Styler.applymap()。请使用新的Styler.map()方法代替(GH 52708

  • 废弃了DataFrame.applymap()。请使用新的DataFrame.map()方法代替(GH 52353

  • 废弃了DataFrame.swapaxes()Series.swapaxes(),请使用DataFrame.transpose()Series.transpose()代替(GH 51946

  • PeriodArray构造函数中废弃了freq参数,请传递dtype代替(GH 52462

  • take()中不再允许使用非标准输入,传入numpy.ndarrayExtensionArrayIndexSeriesGH 52981

  • 不再允许在isin()value_counts()unique()factorize()中使用非标准序列,在调用之前转换为numpy.ndarrayIndexExtensionArraySeriesGH 52986

  • 使用axis=NoneDataFrame缩减操作sumprodstdvarsem的行为将被弃用,在未来版本中,这将在两个轴上操作,返回一个标量,而不是像axis=0那样操作;请注意,这也会影响 numpy 函数,例如np.sum(df)([GH 21597](https://github.com/pandas-dev/pandas/issues/21597)

  • DataFrame的列全部为 NA 时,concat()的行为将被弃用,在未来版本中,当确定结果 dtype 时,这些列将不会被丢弃(GH 40893

  • 未来版本中,Series.dt.to_pydatetime()的行为将被弃用,将返回包含 python datetime对象而不是日期时间ndarraySeries;这与其他Series.dt属性的行为相匹配(GH 20306

  • 在 pandas 对象和无 dtype 序列(例如listtuple)之间的逻辑操作(|, &, ^)的行为将被弃用,操作之前请将序列包装在Series或 NumPy 数组中(GH 51521

  • Series.apply()中弃用了参数convert_typeGH 52140)。

  • 弃用了将字典传递给SeriesGroupBy.agg()的方法;请传递一个聚合列表(GH 50684)。

  • Categorical构造函数中弃用了fastpath关键字,请改用Categorical.from_codes()GH 20110)。

  • 方法is_bool_dtype()返回对象类型为布尔值的Index时的行为已弃用,返回值为TrueGH 52680)。

  • 弃用了方法Series.bool()DataFrame.bool()GH 51749)。

  • DatetimeIndex构造函数中弃用了未使用的closednormalize关键字(GH 52628)。

  • TimedeltaIndex构造函数中弃用了未使用的closed关键字(GH 52628)。

  • 两个具有不同索引的非布尔值Series之间的逻辑运算已弃用,结果始终强制转换为布尔值类型。在将来的版本中,这将保持输入的返回类型(GH 52500, GH 52538)。

  • 弃用了带有BDay频率的PeriodPeriodDtype,请改用带有BDay频率的DatetimeIndexGH 53446)。

  • 弃用了value_counts(),请改用pd.Series(obj).value_counts()GH 47862)。

  • 废弃了Series.first()DataFrame.first();请使用.loc创建掩码和过滤器代替(GH 45908)

  • 废弃了Series.interpolate()DataFrame.interpolate()用于对象数据类型(GH 53631)

  • 废弃了Series.last()DataFrame.last();请使用.loc创建掩码和过滤器代替(GH 53692)

  • 废弃了在SparseDtype中允许任意的fill_value,在将来的版本中,fill_value将需要与dtype.subtype兼容,即可以由该子类型保存的标量或整数或布尔子类型的NaNGH 23124)

  • 废弃了在DataFrameGroupBy.quantile()SeriesGroupBy.quantile()中允许布尔数据类型,与Series.quantile()DataFrame.quantile()的行为一致(GH 51424)

  • 废弃了testing.assert_series_equal()testing.assert_frame_equal()考虑 NA 值(例如NaNNone等效)的行为(GH 52081)

  • 废弃了将字节输入到read_excel()。要读取文件路径,请使用字符串或类似路径的对象(GH 53767)

  • 弃用从标量数据构造 SparseArray 的方法,请传递一个序列代替(GH 53039

  • DataFrame.replace()Series.replace() 中,当 value 未指定时,弃用回退到填充的方法,使用非字典样式的 to_replace 替代(GH 33302

  • 弃用在 read_json() 中直接输入 JSON 文本字符串的方法。请改为将文字 JSON 字符串输入包装在 io.StringIO 中(GH 53409

  • 弃用在 read_xml() 中直接输入文字字符串的方法。请改为使用 io.StringIO / io.BytesIO 包装文字字符串/字节的输入(GH 53767

  • 弃用在 read_html() 中直接输入文字字符串/字节的方法。请改为使用 io.StringIO / io.BytesIO 包装文字字符串/字节的输入(GH 53767

  • 弃用选项 mode.use_inf_as_na,请在之前将 inf 条目转换为 NaNGH 51684

  • DataFrameGroupBy.get_group() 中,弃用参数 objGH 53545

  • 弃用在 SeriesSeries.__getitem__()Series.__setitem__() 上进行位置索引。在将来版本中,ser[item] 将始终将 item 解释为标签,而不是位置(GH 50617

  • .agg.apply.transform中弃用替换内置和 NumPy 函数的方法;改用相应的字符串别名(例如 "sum" 代替 sumnp.sum)替代(GH 53425

  • 弃用在 to_timedelta() 中使用字符串 TtLl 表示单位的方法(GH 52536

  • 弃用 .ExtensionArray.fillna 中的 “method” 和 “limit” 关键字,请改为实现 _pad_or_backfillGH 53621

  • 弃用了 DataFrame.replace()Series.replace() 方法中的 methodlimit 关键词(GH 33302

  • 弃用了 Series.fillna()DataFrame.fillna()SeriesGroupBy.fillna()DataFrameGroupBy.fillna()Resampler.fillna() 方法中的 methodlimit 关键词,改用 obj.bfill()obj.ffill() 替代(GH 53394

  • 弃用了在浮点类型索引对象上使用整数切片的 Series.__getitem__()Series.__setitem__()DataFrame.__getitem__()DataFrame.__setitem__() 的行为,在未来的版本中,这将被视为位置索引(GH 49612

  • 弃用了在 pandas.array() 中使用不支持的 datetime64 和 timedelta64 分辨率的值。支持的分辨率有:"s"、"ms"、"us"、"ns"(GH 53058

  • 弃用了 Series.interpolate()DataFrame.interpolate() 中值为 "pad""ffill""bfill""backfill" 的选项,改用 obj.ffill()obj.bfill() 替代(GH 53581

  • 弃用了Index.argmax()Index.argmin()Series.argmax()Series.argmin()在全为 NA 且skipna=True或任何 NA 且skipna=False时��回-1 的行为;在将来的版本中,这将引发ValueErrorGH 33941, GH 33942

  • DataFrame.to_sql()中不再允许非关键字参数,除了nameconGH 54229)。

  • 弃用了在同时传递freqfill_valueDataFrame.shift()Series.shift()DataFrameGroupBy.shift()时静默忽略fill_value的行为;在将来的版本中,这将引发ValueErrorGH 53832

弃用了类似设置项的 Series 操作中的静默提升 dtype

PDEP-6: pandas.pydata.org/pdeps/0006-ban-upcasting.html

对 Series(或 DataFrame 列)进行类似设置项的操作,会静默地提升 dtype,已被弃用并显示警告。受影响操作的示例有:

  • ser.fillna('foo', inplace=True)

  • ser.where(ser.isna(), 'foo', inplace=True)

  • ser.iloc[indexer] = 'foo'

  • ser.loc[indexer] = 'foo'

  • df.iloc[indexer, 0] = 'foo'

  • df.loc[indexer, 'a'] = 'foo'

  • ser[indexer] = 'foo'

其中ser是一个Seriesdf是一个DataFrame,而indexer可以是切片、掩码、单个值、值列表或数组,或任何其他允许的索引器。

在将来的版本中,这些将引发错误���您应该先转换为一个公共 dtype。

先前行为

In [1]: ser = pd.Series([1, 2, 3])

In [2]: ser
Out[2]:
0    1
1    2
2    3
dtype: int64

In [3]: ser[0] = 'not an int64'

In [4]: ser
Out[4]:
0    not an int64
1               2
2               3
dtype: object 

新行为

In [1]: ser = pd.Series([1, 2, 3])

In [2]: ser
Out[2]:
0    1
1    2
2    3
dtype: int64

In [3]: ser[0] = 'not an int64'
FutureWarning:
 Setting an item of incompatible dtype is deprecated and will raise an error in a future version of pandas.
 Value 'not an int64' has dtype incompatible with int64, please explicitly cast to a compatible dtype first.

In [4]: ser
Out[4]:
0    not an int64
1               2
2               3
dtype: object 

为保留当前行为,在上述情况下,您可以先将ser转换为object类型:

In [21]: ser = pd.Series([1, 2, 3])

In [22]: ser = ser.astype('object')

In [23]: ser[0] = 'not an int64'

In [24]: ser
Out[24]: 
0    not an int64
1               2
2               3
dtype: object 

根据用例,可能更适合转换为不同的 dtype。例如,在以下情况下,我们转换为float64

In [25]: ser = pd.Series([1, 2, 3])

In [26]: ser = ser.astype('float64')

In [27]: ser[0] = 1.1

In [28]: ser
Out[28]: 
0    1.1
1    2.0
2    3.0
dtype: float64 

欲了解更多信息,请参阅pandas.pydata.org/pdeps/0006-ban-upcasting.html

弃用了解析混合时区的日期时间

弃用了解析混合时区的日期时间,除非用户将utc=True传递给to_datetime() (GH 50887)

之前的行为

In [7]: data = ["2020-01-01 00:00:00+06:00", "2020-01-01 00:00:00+01:00"]

In [8]:  pd.to_datetime(data, utc=False)
Out[8]:
Index([2020-01-01 00:00:00+06:00, 2020-01-01 00:00:00+01:00], dtype='object') 

新行为

In [9]: pd.to_datetime(data, utc=False)
FutureWarning:
 In a future version of pandas, parsing datetimes with mixed time zones will raise
 a warning unless `utc=True`. Please specify `utc=True` to opt in to the new behaviour
 and silence this warning. To create a `Series` with mixed offsets and `object` dtype,
 please use `apply` and `datetime.datetime.strptime`.
Index([2020-01-01 00:00:00+06:00, 2020-01-01 00:00:00+01:00], dtype='object') 

为了消除此警告并在将来版本的 pandas 中避免错误,请指定utc=True

In [29]: data = ["2020-01-01 00:00:00+06:00", "2020-01-01 00:00:00+01:00"]

In [30]: pd.to_datetime(data, utc=True)
Out[30]: DatetimeIndex(['2019-12-31 18:00:00+00:00', '2019-12-31 23:00:00+00:00'], dtype='datetime64[ns, UTC]', freq=None) 

要创建一个具有混合偏移和object dtype 的Series,请使用applydatetime.datetime.strptime

In [31]: import datetime as dt

In [32]: data = ["2020-01-01 00:00:00+06:00", "2020-01-01 00:00:00+01:00"]

In [33]: pd.Series(data).apply(lambda x: dt.datetime.strptime(x, '%Y-%m-%d %H:%M:%S%z'))
Out[33]: 
0    2020-01-01 00:00:00+06:00
1    2020-01-01 00:00:00+01:00
dtype: object 

其他弃用

  • 弃用了DataFrameGroupBy.dtypes,请检查底层对象上的dtypes代替 (GH 51045)

  • 弃用了DataFrame._dataSeries._data,请改用公共 API (GH 33333)。

  • 当要连接的任何对象的长度为 0 时,弃用了concat() 的行为;在过去,当确定结果 dtype 时,空对象的 dtype 会被忽略,在将来的版本中,它们将不再被忽略 (GH 39122)

  • 弃用了Categorical.to_list(),请使用obj.tolist()代替 (GH 51254)

  • 弃用了带有 datetime64 或PeriodDtype 值的DataFrameGroupBy.all()DataFrameGroupBy.any(),与SeriesDataFrame弃用一致 (GH 34479)

  • 弃用了在DataFrame.ewm()DataFrame.rolling()DataFrame.expanding()中使用axis=1,请在调用方法之前转置 (GH 51778)

  • 弃用了在DataFrame.groupby()Grouper构造函数中使用axis=1,请改用frame.T.groupby(...) (GH 51203)

  • Series.align()DataFrame.align()中弃用了broadcast_axis关键字,在调用align之前使用left = DataFrame({col: left for col in right.columns}, index=right.index)进行向上转换(GH 51856)

  • Index.fillna()中弃用了downcast关键字(GH 53956)

  • DataFrame.pct_change()Series.pct_change()DataFrameGroupBy.pct_change()SeriesGroupBy.pct_change()中弃用了fill_methodlimit关键字,显式调用例如DataFrame.ffill()DataFrame.bfill()在调用pct_change之前代替(GH 53491)

  • DataFrame.align()Series.align()中弃用了methodlimitfill_axis关键字,显式在对齐结果上调用DataFrame.fillna()Series.fillna()代替(GH 51856)

  • Rolling.quantile()Expanding.quantile()中弃用了quantile关键字,改名为qGH 52550)

  • DataFrame.take() 中弃用了接受切片的功能,请改为调用 obj[slicer] 或传递整数序列代替 (GH 51539)

  • 弃用了在所有-NA 条目或任何-NA 和skipna=False情况下 DataFrame.idxmax()DataFrame.idxmin()Series.idxmax()Series.idxmin() 的行为; 在将来的版本中,它们将引发 ValueError (GH 51276)

  • 弃用了对子类化 Index 的显式支持 (GH 45289)

  • 弃用了使给定给 Series.agg() 的函数尝试对 Series 的每个元素进行操作,并仅在元素级操作失败时才对整个 Series 进行操作。在将来,给定给 Series.agg() 的函数将始终仅对整个 Series 进行操作。要保持当前行为,请改用 Series.transform() (GH 53325)

  • 弃用了使给定给 DataFrame.agg() 的函数列表中的函数尝试对 DataFrame 的每个元素进行操作,并仅在元素级操作失败时才对 DataFrame 的列进行操作。要保持当前行为,请改用 DataFrame.transform() (GH 53325)

  • DataFrame.from_records() 中弃用了传递 DataFrame,请改用 DataFrame.set_index()DataFrame.drop() 代替(GH 51353)

  • 在将字符串解析为日期时间时,默默弃用了无法识别的时区(GH 18702)

  • DataFrame.ewm()Series.ewm()DataFrame.rolling()Series.rolling()DataFrame.expanding()Series.expanding() 中弃用了 axis 关键字(GH 51778)

  • DataFrame.resample()Series.resample() 中弃用了 axis 关键字(GH 51778)

  • Series.interpolate()DataFrame.interpolate()Series.fillna()DataFrame.fillna()Series.ffill()DataFrame.ffill()Series.bfill()DataFrame.bfill() 中弃用了 downcast 关键字(GH 40988)

  • 在未来的版本中,弃用了concat()len(keys) != len(objs)的行为,将会引发异常而不是截断为两个序列中较短的一个(GH 43485

  • 在存在 NA 值时,弃用了Series.argsort()的行为;在未来的版本中,这些值将在最后排序,而不是返回-1(GH 54219

  • DataFrame.groupby()Series.groupby()中弃用了observed=False的默认值;这在未来的版本中将默认为TrueGH 43999

  • SeriesGroupBy.aggregate()聚合中,停用了将group.name固定到每个组的操作;如果您的操作需要使用 groupby 键,请遍历 groupby 对象而不是利用group.nameGH 41090

  • DataFrameGroupBy.idxmax()DataFrameGroupBy.idxmin()DataFrameGroupBy.fillna()DataFrameGroupBy.take()DataFrameGroupBy.skew()DataFrameGroupBy.rank()DataFrameGroupBy.cumprod()DataFrameGroupBy.cumsum()DataFrameGroupBy.cummax()DataFrameGroupBy.cummin()DataFrameGroupBy.pct_change()DataFrameGroupBy.diff()DataFrameGroupBy.shift(),和DataFrameGroupBy.corrwith()中弃用了axis关键字;对于axis=1,操作的是底层的DataFrame而不是(GH 50405GH 51046)。

  • 使用 as_index=FalseDataFrameGroupBy 在结果中不包含分组,当它们不是 DataFrame 的列时已被废弃(GH 49519

  • 废弃的 is_categorical_dtype(),请使用 isinstance(obj.dtype, pd.CategoricalDtype) 代替(GH 52527

  • 废弃的 is_datetime64tz_dtype(),请使用 isinstance(dtype, pd.DatetimeTZDtype) 代替(GH 52607

  • 废弃的 is_int64_dtype(),请使用 dtype == np.dtype(np.int64) 代替(GH 52564

  • 废弃的 is_interval_dtype(),请使用 isinstance(dtype, pd.IntervalDtype) 代替(GH 52607

  • 废弃的 is_period_dtype(),请使用 isinstance(dtype, pd.PeriodDtype) 代替(GH 52642

  • 废弃的 is_sparse(),请使用 isinstance(dtype, pd.SparseDtype) 代替(GH 52642

  • 废弃的 Styler.applymap_index()。请使用新的 Styler.map_index() 方法代替(GH 52708

  • 废弃的 Styler.applymap()。请使用新的 Styler.map() 方法代替(GH 52708

  • 废弃的 DataFrame.applymap()。请使用新的 DataFrame.map() 方法代替(GH 52353

  • 废弃的 DataFrame.swapaxes()Series.swapaxes(),请使用 DataFrame.transpose()Series.transpose() 代替(GH 51946

  • PeriodArray 构造函数中的 freq 参数已废弃,改用 dtype 代替(GH 52462

  • 弃用在 take() 中允许非标准输入的行为,请传递一个 numpy.ndarrayExtensionArrayIndexSeriesGH 52981

  • 弃用在 isin()value_counts()unique()factorize() 中允许非标准序列的行为,在调用之前,请将其转换为 numpy.ndarrayIndexExtensionArraySeriesGH 52986

  • 弃用在 DataFrame 缩减操作 sumprodstdvarsem 中使用 axis=None 的行为,将来版本中,这将在两个轴上操作,返回标量而不是像 axis=0 一样的行为;注意,这也会影响到 numpy 函数,例如 np.sum(df)GH 21597

  • DataFrame 的列全部为 NA 时,弃用 concat() 的行为,将来版本中,这些列将不会在确定结果 dtype 时被丢弃(GH 40893

  • 将来版本中,Series.dt.to_pydatetime() 的行为将被弃用,将返回包含 Python datetime 对象而不是 datetime 数组的 Series;这与其他 Series.dt 属性的行为一致(GH 20306)

  • 弃用在 pandas 对象和无 dtype 序列(例如 listtuple)之间的逻辑操作 (|, &, ^),在操作之前请将序列包装在一个 Series 或 NumPy 数组中(GH 51521

  • Series.apply() 中弃用了参数 convert_typeGH 52140)

  • 弃用了将字典传递给 SeriesGroupBy.agg();请传递一个聚合列表代替(GH 50684)

  • Categorical 构造函数中弃用了 fastpath 关键字,请改用 Categorical.from_codes()GH 20110)

  • is_bool_dtype() 方法的行为已被弃用,对于布尔对象的对象 dtype Index,将返回TrueGH 52680)

  • 弃用了方法 Series.bool()DataFrame.bool()GH 51749)

  • DatetimeIndex 构造函数中弃用了未使用的 closednormalize 关键字(GH 52628)

  • TimedeltaIndex 构造函数中弃用了未使用的 closed 关键字(GH 52628)

  • 弃用了两个非布尔 Series 之间的逻辑操作,它们具有不同的索引,结果始终强制转换为布尔 dtype。在未来的版本中,这将保持输入的返回类型(GH 52500, GH 52538)

  • PeriodPeriodDtype 已被弃用,带有 BDay 频率,请改用带有 BDay 频率的 DatetimeIndexGH 53446)

  • 弃用了 value_counts(),请改用 pd.Series(obj).value_counts()GH 47862)

  • 废弃了Series.first()DataFrame.first();改用创建掩码并使用.loc进行过滤(GH 45908)

  • 废弃了Series.interpolate()DataFrame.interpolate()用于对象 dtype(GH 53631)

  • 废弃了Series.last()DataFrame.last();改用创建掩码并使用.loc进行过滤(GH 53692)

  • 废弃了在SparseDtype中允许任意fill_value,在将来的版本中,fill_value将需要与dtype.subtype兼容,要么是可以由该 subtype 保存的标量,要么是整数或布尔子类型的NaNGH 23124)

  • 废弃了在DataFrameGroupBy.quantile()SeriesGroupBy.quantile()中允许布尔 dtype,与Series.quantile()DataFrame.quantile()的行为一致(GH 51424)

  • 废弃了对testing.assert_series_equal()testing.assert_frame_equal()的行为,考虑 NA 类似值(例如NaN vs None视为等价)(GH 52081)

  • 废弃了将字节输入到read_excel()。要读取文件路径,请使用字符串或类似路径的对象(GH 53767)

  • 废弃使用标量数据构造 SparseArray,请传递一个序列代替(GH 53039

  • 废弃在 DataFrame.replace()Series.replace() 中当 value 未指定时回退到填充的操作,使用非字典形式的 to_replaceGH 33302

  • 废弃对 read_json() 的字面 json 输入。请将字面 json 字符串输入包装在 io.StringIO 中(GH 53409

  • 废弃对 read_xml() 的字面字符串输入。请改用 io.StringIO / io.BytesIO 包装字面字符串/字节输入(GH 53767

  • 废弃对 read_html() 的字面字符串/字节输入。请改用 io.StringIO / io.BytesIO 包装字面字符串/字节输入(GH 53767

  • 废弃选项 mode.use_inf_as_na,在之前将 inf 条目转换为 NaNGH 51684

  • 废弃 DataFrameGroupBy.get_group() 中的参数 objGH 53545

  • 废弃在 Series 上使用位置索引的 Series.__getitem__()Series.__setitem__(),在将来的版本中,ser[item]始终item 解释为标签,而不是位置(GH 50617

  • 废弃在 .agg.apply.transform 中替换内置和 NumPy 函数;请使用相应的字符串别名(例如 "sum" 代替 sumnp.sum)(GH 53425

  • 废弃在 to_timedelta() 中使用 TtLl 表示单位的字符串(GH 52536

  • 废弃在 .ExtensionArray.fillna 中的 “method” 和 “limit” 关键字,改用 _pad_or_backfill 实现(GH 53621

  • 废弃了DataFrame.replace()Series.replace()中的methodlimit关键字(GH 33302)

  • 废弃了Series.fillna()DataFrame.fillna()SeriesGroupBy.fillna()DataFrameGroupBy.fillna()Resampler.fillna()中的methodlimit关键字,改用obj.bfill()obj.ffill()代替(GH 53394)

  • 废弃了在具有浮点类型索引的对象上使用Series.__getitem__()Series.__setitem__()DataFrame.__getitem__()DataFrame.__setitem__()进行整数切片的行为,在将来的版本中,这将被视为位置索引(GH 49612)

  • 废弃了在pandas.array()中使用不支持的 datetime64 和 timedelta64 分辨率。支持的分辨率有:"s"、"ms"、"us"、"ns"分辨率(GH 53058)

  • 废弃了Series.interpolate()DataFrame.interpolate()中的值"pad""ffill""bfill""backfill",请改用obj.ffill()obj.bfill()代替(GH 53581)

  • 在将所有值为 NA 且 skipna=True 或任何值为 NA 且 skipna=False 的情况下,不再返回 -1,而是引发 ValueError,这涉及 Index.argmax()Index.argmin()Series.argmax()Series.argmin() 的行为;在未来版本中将引发 ValueErrorGH 33941GH 33942

  • 不再允许在 DataFrame.to_sql() 中使用非关键字参数,除了 nameconGH 54229

  • 在未来版本中,当同时将 freqfill_value 传递给 DataFrame.shift()Series.shift()DataFrameGroupBy.shift() 时,不再默默忽略 fill_value,而是引发 ValueErrorGH 53832

性能改进

  • 在使用同类 np.float64np.float32 数据类型的情况下,concat() 的性能有所提高(GH 52685

  • 对于不包含字符串的对象列,factorize() 的性能有所提高(GH 51921

  • 在读取远程 URI 文件路径时,read_orc() 的性能有所提高(GH 51609

  • 在使用 engine="pyarrow" 读取远程文件时,read_parquet()DataFrame.to_parquet() 的性能有所提高(GH 51609

  • 在使用 use_nullable_dtypes=True 时,read_parquet() 在字符串列上的性能有所提高(GH 47345

  • DataFrame.clip()Series.clip() 中的性能改进(GH 51472)

  • DataFrame.filter() 中给定 items 时的性能改进(GH 52941)

  • 在扩展数组数据类型的 DataFrame.first_valid_index()DataFrame.last_valid_index() 中的性能改进(GH 51549)

  • cond 由扩展数据类型支持时的 DataFrame.where() 性能改进(GH 51574)

  • MultiIndex.set_levels()MultiIndex.set_codes() 中当 verify_integrity=True 时的性能改进(GH 51873)

  • MultiIndex.sortlevel() 中对 ascending 是列表时的性能改进(GH 51612)

  • Series.combine_first() 中的性能改进(GH 51777)

  • 在数组不包含空值时的 fillna() 性能改进(GH 51635)

  • 在数组没有空值或全部为空值时的 isna() 性能改进(GH 51630)

  • 在将字符串解析为 boolean[pyarrow] 类型时的性能改进(GH 51730)

  • 在从其他索引切片的 Index 中搜索时的性能改进(GH 51738)

  • concat() 中的性能改进(GH 52291, GH 52290)

  • Period 类的默认格式化器 (period_format) 现在显著地(~两倍)更快。这提高了 str(Period)repr(Period)Period.strftime(fmt=None) 的性能,以及 .PeriodArray.strftime(fmt=None).PeriodIndex.strftime(fmt=None).PeriodIndex.format(fmt=None)。涉及默认 date_formatPeriodArrayPeriodIndexto_csv 操作也显著加速了(GH 51459

  • 访问 arrays.IntegerArrays.dtypearrays.FloatingArray.dtype 的性能改进(GH 52998

  • DataFrameGroupBy/SeriesGroupBy 聚合(例如 DataFrameGroupBy.sum())使用 engine="numba" 的性能改进(GH 53731

  • 在带有扩展数据类型的 DataFrameaxis=1 归纳中的性能改进(GH 54341

  • 在带有扩展数据类型的 DataFrameaxis=None 归纳中的性能改进(GH 54308

  • 在索引/列值已排序时的 MultiIndex 和多列操作(例如 DataFrame.sort_values()DataFrame.groupby()Series.unstack())中的性能改进(GH 53806

  • Series 归纳中的性能改进(GH 52341

  • concat() 函数中当 axis=1 且对象具有不同索引时的性能改进(GH 52541

  • concat() 当连接轴是 MultiIndex 时有性能改进(GH 53574)。

  • merge() 在 PyArrow 支持的字符串上有性能改进(GH 54443)。

  • read_csv() 使用 engine="c" 时有性能改进(GH 52632)。

  • ArrowExtensionArray.to_numpy() 有性能改进(GH 52525)。

  • DataFrameGroupBy.groups() 有性能改进(GH 53088)。

  • DataFrame.astype()dtype 是扩展类型时有性能改进(GH 54299)。

  • DataFrame.iloc() 在输入为单个整数且 DataFrame 受扩展类型支持时有性能改进(GH 54508)。

  • DataFrame.isin() 在扩展类型上有性能改进(GH 53514)。

  • DataFrame.loc() 在选择行和列时有性能改进(GH 53014)。

  • DataFrame.transpose() 在转置单个 PyArrow 类型的 DataFrame 时有性能改进(GH 54224)。

  • DataFrame.transpose() 在转置单个掩码类型的 DataFrame 时有性能改进,例如 Int64GH 52836)。

  • Series.add() 在 PyArrow 字符串和二进制类型时有性能改进(GH 53150)。

  • Series.corr()Series.cov() 中的性能改进,针对扩展的数据类型(GH 52502

  • Series.drop_duplicates() 针对 ArrowDtype 的性能改进(GH 54667

  • 在具有 PyArrow 数据类型的情况下,Series.ffill()Series.bfill()DataFrame.ffill()DataFrame.bfill() 的性能改进(GH 53950

  • Series.str.get_dummies() 中的性能改进,针对 PyArrow 支持的字符串(GH 53655

  • Series.str.get() 在 PyArrow 支持的字符串中的性能改进(GH 53152

  • Series.str.split() 在 PyArrow 支持的字符串中使用 expand=True 时的性能改进(GH 53585

  • 当 dtype 为 NumPy 浮点数据类型且 na_valuenp.nan 时,Series.to_numpy() 的性能改进(GH 52430

  • 在从 PyArrow 时间戳或持续时间数据类型转换为 NumPy 时,astype() 的性能改进(GH 53326

  • 各种 MultiIndex 设置和索引操作的性能改进(GH 53955

  • arrays.IntegerArrayarrays.FloatingArray 上执行各种重塑操作时的性能改进,避免进行不必要的验证(GH 53013

  • 使用 PyArrow 时间戳和持续时间数据类型进行索引时的性能改进(GH 53368)

  • 当将数组传递给RangeIndex.take()DataFrame.loc()DataFrame.iloc()时,性能改进,并且 DataFrame 使用 RangeIndex 时(GH 53387)

Bug 修复

Categorical

  • CategoricalIndex.remove_categories()中的错误,有序类别将不会被维护(GH 53935).

  • 在具有只读空值掩码的可空数组中,使用dtype="category"Series.astype()中的错误(GH 53658)

  • Series.map()中的错误,如果系列持有Categorical,则na_action参数的值不会被使用(GH 22527).

Datetimelike

  • DatetimeIndex.map()na_action="ignore"下现在按预期工作(GH 51644)

  • 如果切片边界中的任一边界不在索引中,则DatetimeIndex.slice_indexer()现在对非单调索引引发KeyError;此行为先前已被弃用,但处理不一致(GH 53983)

  • 在将DateOffset对象乘以常数时,DateOffset中存在不一致行为的错误(GH 47953)

  • freqDateOffset且具有nanoseconds时的date_range()中的错误(GH 46877)

  • 在将包含 PyArrow 时间戳的SeriesDataFrame转换为 numpy 日期时间的to_datetime()中的错误(GH 52545)

  • DatetimeArray.map()DatetimeIndex.map()中存在错误,提供的可调用函数是数组级别操作而不是元素级别操作(GH 51977)

  • 在使用 PyArrow 支持的日期类型时,DataFrame.to_sql()引发ValueError错误(GH 53854)

  • Timestamp.date()Timestamp.isocalendar()Timestamp.timetuple()Timestamp.toordinal()中,对于 Python 标准库的 datetime 模块不支持的输入,返回结果错误(GH 53668)

  • 在接近实现边界的值上使用Timestamp.round()返回错误结果而不是引发OutOfBoundsDatetime错误(GH 51494)

  • 从日期时间标量构造SeriesDataFrame时,总是推断纳秒分辨率而不是从输入中推断(GH 52212)

  • 从不带日期的时间字符串构造Timestamp存在错误,推断出错误的单位(GH 54097)

  • 使用ts_input=pd.NA构造Timestamp时引发TypeError错误(GH 45481)

  • 解析带有工作日但没有日期的日期时间字符串,例如“2023 年 9 月星期四”,错误地引发AttributeError而不是ValueErrorGH 52659)

  • dtype为时区感知的非纳秒分辨率日期时间时,Seriesrepr存在错误,引发OutOfBoundsDatetime错误(GH 54623)

时间差

  • TimedeltaIndex中的错误,除法或乘法导致.freq为“0 Days”而不是NoneGH 51575

  • Timedelta中的错误,NumPy 的timedelta64对象未正确引发ValueErrorGH 52806

  • to_timedelta()中的错误,将包含pyarrow.durationSeriesDataFrame转换为 NumPy 的timedelta64时出错(GH 54298

  • Timedelta.__hash__()中的错误,在某些大值的秒分辨率上引发OutOfBoundsTimedeltaGH 54037

  • Timedelta.round()中的错误,对接近实现边界的值返回不正确的结果而不是引发OutOfBoundsTimedeltaGH 51494

  • TimedeltaIndex.map()中的错误,使用na_action="ignore"时出错(GH 51644

  • arrays.TimedeltaArray.map()TimedeltaIndex.map()中的错误,提供的可调用函数是数组级别操作而不是元素级别操作(GH 51977

时区

  • infer_freq()中的错误,对于时区感知时间戳的Series引发TypeErrorGH 52456

  • DatetimeTZDtype.base()中的错误,始终返回具有纳秒分辨率的 NumPy dtype(GH 52705

数值

  • RangeIndex中的错误,在被减数为数值时,设置step不正确,而减数为RangeIndexGH 53255

  • Series.corr()Series.cov()中的错误,对于掩码 dtype 引发AttributeErrorGH 51422

  • 在所有零值的 NumPy 数据上调用Series.kurt()Series.skew() 返回 Python 类型而不是 NumPy 类型的错误(GH 53482)

  • Bug in Series.mean(), DataFrame.mean() 中包含可转换为数字的字符串(例如“2”)的对象数据类型返回不正确的数值结果;现在会引发TypeErrorGH 36703, GH 44008)

  • Bug in DataFrame.corrwith() 对于 PyArrow-backed 数据类型引发NotImplementedError的错误(GH 52314)

  • Bug in DataFrame.size()Series.size() 返回 64 位整数而不是 Python int 的错误(GH 52897)

  • Bug in DateFrame.dot() 返回object数据类型而不是ArrowDtype数据的错误(GH 53979)

  • Bug in Series.any(), Series.all(), DataFrame.any(), 和 DataFrame.all()bool_only的默认值设置为None而不是False的错误;这个更改不应对用户产生影响(GH 53258)

  • Bug in Series.corr()Series.cov() 对于掩码数据类型引发AttributeError的错误(GH 51422)

  • 当包含可以转换为数字的字符串的 object-dtype 值(例如“2”)时,Series.median()DataFrame.median() 中存在 Bug,返回不正确的数值结果;现在会引发 TypeError (GH 34671)

  • 将 dtype 为 uint64 的数据转换为 int64 时,Series.sum() 中存在 Bug (GH 53401)

转换

  • 如果 DataFrame 包含比浮点双精度表示法能表示的整数位数更多的整数,则 DataFrame.style.to_latex()DataFrame.style.to_html() 中存在 Bug (GH 52272)

  • 当给定 datetime64timedelta64 dtype 并且单位为“s”、“us”或“ms”时,array() 中存在 Bug,返回 NumpyExtensionArray 而不是 DatetimeArrayTimedeltaArray (GH 52859)

  • 当给定空列表且没有 dtype 时,array() 中存在 Bug,返回 NumpyExtensionArray 而不是 FloatingArray (GH 54371)

  • pyarrow.timestamppyarrow.duration 类型的非纳秒单位时,ArrowDtype.numpy_dtype() 中存在 Bug,返回纳秒单位 (GH 51800)

  • 当列的 dtype 是 np.record 时,DataFrame.__repr__() 不正确地引发 TypeError (GH 48526)

  • 当设置 use_numba 时,DataFrame.info() 中存在 Bug,抛出 ValueError (GH 51922)

  • locnp.int64 时,DataFrame.insert() 中存在 Bug,抛出 TypeError (GH 53193)

  • 在存储和检索时,HDFStore.select()会丢失大整数的精度(GH 54186)。

  • Series.astype()不支持object_的错误修复(GH 54251)。

字符串

  • 在迭代时,Series.str()存在不引发TypeError的错误(GH 54173)。

  • 用于具有字符串 dtype 列的DataFramerepr存在错误(GH 54797)。

区间

  • target为只读数组时,IntervalIndex.get_indexer()IntervalIndex.get_indexer_nonunique()会引发错误(GH 53703)。

  • 当删除时,IntervalDtype中的对象可能被保持活动(GH 54184)。

  • 当使用浮点数step时,interval_range()会产生错误的区间(GH 54477)。

索引

  • 修复了在将DataFrame设置到重复列时DataFrame.__setitem__()丢失 dtype 的错误(GH 53143)。

  • 在混合非数值类型和值不为NaN的布尔掩码和DataFrame.putmask()时,DataFrame.__setitem__()存在错误引发TypeErrorGH 53291)。

  • 当将nan作为唯一元素时,使用DataFrame.iloc()存在错误(GH 52234)。

  • 当将Series分配给预定义索引的object dtype Series时,Series.loc()Series转换为np.dnarray的错误(GH 48933)。

缺失

  • DataFrame.interpolate()中的错误,在method"pad""ffill""bfill""backfill"时无法填充数据(GH 53898)

  • DataFrame.interpolate()中的错误,在DataFrame为空时忽略inplaceGH 53199)

  • Series.idxmin()Series.idxmax()DataFrame.idxmin()DataFrame.idxmax()中的错误,在包含NaTDatetimeIndex索引中,错误地返回NaN而不是NaTGH 43587)

  • Series.interpolate()DataFrame.interpolate()中的错误,在无效的downcast关键字上未引发异常,该关键字只能是None"infer"GH 53103)

  • Series.interpolate()DataFrame.interpolate()中的错误,对复杂 dtype 填充NaN条目时出现错误(GH 53635)

MultiIndex

  • MultiIndex.set_levels()中的错误,未保留Categorical的 dtype(GH 52125)

  • 显示MultiIndex时出现的错误,元素过长(GH 52960)

I/O

  • DataFrame.to_orc() 现在在给定非默认 Index 时会引发 ValueError (GH 51828)

  • DataFrame.to_sql() 现在在使用 SQLAlchemy 连接时,当参数 name 为空时会引发 ValueError (GH 52675)

  • json_normalize() 存在一个 bug,无法解析元数据字段列表类型 (GH 37782)

  • read_csv() 存在一个 bug,在 parse_dates 设置为列表或字典时,使用 engine="pyarrow" 会报错 (GH 47961)

  • read_csv() 存在一个 bug,当指定 dtypeindex_col 时,使用 engine="pyarrow" 报错 (GH 53229)

  • read_hdf() 存在一个 bug,在引发 IndexError 后未正确关闭存储 (GH 52781)

  • read_html() 存在一个 bug,样式元素会被读取到 DataFrame 中 (GH 52197)

  • read_html() 存在一个 bug,尾部文本和包含 display:none 样式的元素一同被移除 (GH 51629)

  • read_sql_table() 在读取视图时会引发异常 (GH 52969)

  • read_sql() 在读取具有相同列名的多个时区感知列时存在一个 bug (GH 44421)

  • read_xml() 存在一个 bug,会剥离字符串数据中的空白字符 (GH 53811)

  • DataFrame.to_html() 存在一个 bug,多级索引列情况下 colspace 被错误应用 (GH 53885)

  • 修复了DataFrame.to_html()中对具有复杂 dtype 的空DataFrame进行转换引发ValueError的错误(GH 54167

  • 修复了DataFrame.to_json()DateTimeArray/DateTimeIndex的非纳秒精度无法正确序列化的错误(GH 53686

  • 修复了写入和读取空的 Stata dta 文件时丢失 dtype 信息的错误(GH 46240

  • 修复了bz2被视为硬性要求的错误(GH 53857

期间

  • 修复了PeriodDtype构造函数在未传递参数或传递None时未引发TypeError的错误(GH 27388

  • 修复了PeriodDtype构造函数在不同的DateOffset freq输入下错误地返回相同的normalize的错误(GH 24121

  • 修复了PeriodDtype构造函数在传递无效类型时引发ValueError而不是TypeError的错误(GH 51790

  • 修复了PeriodDtype中对象在删除时可能被保持活动的错误(GH 54184

  • 修复了使用engine="pyarrow"read_csv()未将空字符串处理为 null 值的错误(GH 52087

  • 修复了使用engine="pyarrow"read_csv()返回object dtype 列而不是float64 dtype 列的错误,对于所有值为空的列使用engine="pyarrow"GH 52087

  • 修复了Period.now()不接受freq参数作为关键字参数的错误(GH 53369

  • 修复了PeriodIndex.map()na_action="ignore"的错误(GH 51644

  • 修复了arrays.PeriodArray.map()PeriodIndex.map()中提供的可调用函数是数组级别操作而不是元素级别操作的错误(GH 51977

  • 错误允许使用 CustomBusinessDay 频率构造 PeriodPeriodDtype 的 Bug;请使用 BusinessDay 代替(GH 52534)。

绘图

  • 当以 color=None 调用时,Series.plot() 存在 Bug (GH 51953)。

  • 在以 c="b" 调用时,DataFrame.plot.scatter() 存在 UserWarning 的 Bug 已修复 (GH 53908)。

分组/重新采样/滚动

  • DataFrameGroupBy.idxmin()SeriesGroupBy.idxmin()DataFrameGroupBy.idxmax()SeriesGroupBy.idxmax() 在对空的 DataFrameGroupBy 或 SeriesGroupBy 使用时返回错误的数据类型(GH 51423)。

  • 当传递 na_option="bottom"na_option="top" 时,在可空数据类型上调用 DataFrame.groupby.rank() 的 Bug (GH 54206)。

  • 当在 TimedeltaIndex 上重新采样时,DataFrame.resample()Series.resample() 错误允许非固定 freq 的 Bug (GH 51896)。

  • 在重新采样空数据时,DataFrame.resample()Series.resample() 会丢失时区(GH 53664)。

  • DataFrame.resample()Series.resample() 中的 Bug,在重采样时 origin 不起作用,当值超出轴范围时(GH 53662)。

  • 在指定 min_periods=0 时,加权滚动聚合中的 Bug(GH 51449)。

  • DataFrame.groupby()Series.groupby() 中的 Bug,当分组的 SeriesDataFrame 的索引是 DatetimeIndexTimedeltaIndexPeriodIndex 时,而且 groupby 方法的第一个参数是函数时,该函数对整个索引而不是索引的每个元素进行操作(GH 51979)。

  • DataFrameGroupBy.agg() 中的 Bug,当使用列表时不遵守 as_index=FalseGH 52849)。

  • DataFrameGroupBy.apply() 中的 Bug,当输入的 DataFrame 在进行 groupby 后被子集化为 DataFrame[['a']] 而不是 ['a'])并且给定的可调用函数返回的 Series 的索引不完全相同时,会引发错误(GH 52444)。

  • DataFrameGroupBy.apply() 中的 Bug,当选择多列并提供返回 np.ndarray 结果的函数时引发 TypeErrorGH 18930)。

  • DataFrameGroupBy.groups()SeriesGroupBy.groups()中存在的错误,与另一个键一起使用 datetime 键产生了不正确的组键数量(GH 51158

  • DataFrameGroupBy.quantile()SeriesGroupBy.quantile()中存在的错误,可能会在结果索引上隐式使用sort=False进行排序(GH 53009

  • SeriesGroupBy.size()中存在的错误,对于具有ArrowDtype或掩码 dtype(例如Int64)的数据,dtype 将为np.int64GH 53831

  • DataFrame.groupby()中存在的错误,在结果 groupby 对象上进行列选择时,当通过由单个元素组成的列表进行分组时,未返回名称为元组的名称(GH 53500

  • DataFrameGroupBy.var()SeriesGroupBy.var()中存在的错误,在使用 datetime64、timedelta64 或PeriodDtype值调用时未引发TypeErrorGH 52128, GH 53045

  • DataFrameGroupBy.resample()中存在的错误,使用kind="period"时引发AttributeErrorGH 24103

  • 对于返回空对象的 Resampler.ohlc(),错误导致返回一个 Series 而不是空的 DataFrameGH 42902")

  • 当数据具有 ArrowDtype 或掩码类型(例如 Int64)时,SeriesGroupBy.count()DataFrameGroupBy.count() 中的错误导致数据类型为 np.int64GH 53831

  • 对于使用 dropna="any"dropna="all" 时进行列选择后,SeriesGroupBy.nth()DataFrameGroupBy.nth() 中的错误导致不会对列进行子集化(GH 53518

  • 对于使用 dropna="any"dropna="all" 时进行列选择后 SeriesGroupBy.nth()DataFrameGroupBy.nth() 中的错误导致行被丢弃(GH 53518

  • 对于 np.inf + np.inf(-np.inf) + (-np.inf) 分别相加后,SeriesGroupBy.sum()DataFrameGroupBy.sum() 中的错误导致结果为 np.nan 而不是 np.inf-np.infGH 53606

  • Series.groupby()中的错误,在分组的Series具有DatetimeIndex索引且by参数给定为月份名称的Series时引发错误(GH 48509

重塑

  • concat()中的错误,在一个列具有pa.null()数据类型时,强制转换为object数据类型(GH 53702)

  • crosstab()中的错误,当dropna=False时,结果中不会保留np.nanGH 10772

  • melt()中的错误,variable列会丢失扩展数据类型(GH 54297

  • merge_asof()中的错误导致扩展数据类型引发KeyErrorGH 52904

  • merge_asof()中的错误,对于由只读 ndarrays 支持的数据引发ValueErrorGH 53513

  • merge_asof()中的错误,使用left_index=Trueright_index=True且索引数据类型不匹配时,在某些情况下会给出不正确的结果,而不是引发MergeErrorGH 53870��

  • merge()中的错误,在整数ExtensionDtype和浮点 NumPy 数据类型上合并时引发TypeErrorGH 46178

  • DataFrame.agg()Series.agg()中的错误,对非唯一列进行聚合时,当传递 dist-like 参数时返回的类型不正确(GH 51099

  • DataFrame.combine_first()中的错误,如果other为空,则忽略其他列(GH 53792

  • Bug in DataFrame.idxmin()DataFrame.idxmax(),在空帧时轴 dtype 将丢失(GH 53265)

  • Bug in DataFrame.merge() 在具有单个级别的MultiIndex时未能正确合并(GH 52331)

  • Bug in DataFrame.stack() 当列是MultiIndex且帧包含混合 dtype 时丢失扩展 dtype(GH 45740)

  • Bug in DataFrame.stack() 对列进行字典排序时出现错误(GH 53786)

  • Bug in DataFrame.transpose() 推断对象列的 dtype 时出现错误(GH 51546)

  • Bug in Series.combine_first()int64 dtype 转换为float64并在非常大的整数上丢失精度(GH 51764)

  • Bug when joining empty DataFrame 对象时,连接的索引将是RangeIndex而不是连接的索引类型(GH 52777)

Sparse

  • Bug in SparseDtype 构造函数在给定不兼容的子类型 dtype 时未能引发TypeError,其子类型必须是 NumPy dtype(GH 53160)

  • Bug in arrays.SparseArray.map() 允许填充值包含在稀疏值中(GH 52095)

ExtensionArray

  • Bug in ArrowStringArray 构造函数在字符串字典类型时引发ValueErrorGH 54074)

  • 在使用字典给出具有扩展 dtype 的 Series 时,DataFrame 构造函数未复制的错误(GH 53744

  • ArrowExtensionArray 中存在一个错误,将 pandas 的非纳秒时间对象从非零值转换为零值时出现问题(GH 53171

  • 对于 PyArrow 时间类型,在 Series.quantile() 中引发 ArrowInvalid 的错误(GH 52678

  • Series.rank()Float64 dtype 的小值上返回错误的顺序(GH 52471

  • Series.unique() 中存在一个错误,对带有 NA 值的布尔 ArrowDtype 进行处理时出现问题(GH 54667

  • __iter__()__getitem__() 中返回非纳秒类型的 python datetime 和 timedelta 对象时存在问题(GH 53326

  • 在使用 factorize() 处理 pyarrow.chunked_arraypyarrow.dictionary 类型时,如果有多个 chunk,返回的唯一值不正确(GH 54844

  • ExtensionArray 子类传递给 dtype 关键字时出现错误。现在将引发 UserWarning 以鼓励传递一个实例而不是一个子类(GH 31356, GH 54592

  • 当列具有带有 pyarrow.ExtensionDtypeArrowDtype 时,DataFrame repr 不起作用的错误(GH 54063

  • 对于带有遮罩的 ExtensionDtypes(例如 Float64DtypeBooleanDtype),其 __from_arrow__ 方法不接受 pyarrow.null() 类型的数组(GH 52223

样式化器

  • Styler._copy() 中调用 Styler 的子类中覆盖的方法时存在问题(GH 52728

元数据

  • 修复了 DataFrame.max()DataFrame.min()DataFrame.prod()DataFrame.mean()Series.mode()DataFrame.median()DataFrame.sem()DataFrame.skew()DataFrame.kurt() 中的元数据传播问题(GH 28283

  • 修复了 DataFrame.squeeze()DataFrame.describe() 中的元数据传播问题(GH 28283

  • 修复了 DataFrame.std() 中的元数据传播问题(GH 28283

其他

  • 在存在 NaN 值时,FloatingArray.__contains__ 中的 Bug 错误地返回 FalseGH 52840

  • 在存在 NaN 值时,DataFrameSeries 中的 Bug 引发数据为复杂 dtype 时的问题(GH 53627

  • DatetimeIndex中的 Bug,当传递带有时间的索引的 repr 时,如果时间为午夜且非基于日的频率,将不会打印时间(GH 53470

  • testing.assert_frame_equal()testing.assert_series_equal()中的 Bug 现在对两个不相等的集合抛出断言错误(GH 51727

  • testing.assert_frame_equal() 中的 bug 即使不检查索引类型也会检查类别 dtypes(GH 52126

  • api.interchange.from_dataframe() 中的 bug 没有尊重 allow_copy 参数(GH 54322

  • api.interchange.from_dataframe() 中的 bug 在转换非 pandas tz-aware 数据且包含空值时出现异常(GH 54287

  • 在转换空 DataFrame 对象时 api.interchange.from_dataframe() 中的 bug(GH 53155

  • from_dummies() 中的 bug 导致生成的 Index 与原始 Index 不匹配(GH 54300

  • from_dummies() 中的 bug 导致生成的数据始终是 object dtype 而不是列的 dtype(GH 54300

  • DataFrameGroupBy.first()DataFrameGroupBy.last()SeriesGroupBy.first()SeriesGroupBy.last() 中的 bug 导致空组返回 np.nan 而不是对应的 ExtensionArray NA 值(GH 39098

  • DataFrame.pivot_table() 中的 Bug,将整数的平均值强制转换回整数时出错(GH 16676)。

  • DataFrame.reindex() 中的 Bug,在应该推断为 ExtensionDtypefill_value 时,错误地推断为 object dtype(GH 52586)。

  • DataFrame.shift() 中的 Bug,在具有单个 ExtensionDtype 列的 DataFrame 上,使用 axis=1 时给出不正确的结果(GH 53832)。

  • Index.sort_values() 中的 Bug,在传递 key 时出错(GH 52764)。

  • Series.align()DataFrame.align()Series.reindex()DataFrame.reindex()Series.interpolate()DataFrame.interpolate()中的 Bug,在使用 method=”asfreq” 时未能正确抛出错误(GH 53620)。

  • Series.argsort() 中的 Bug,在传递无效的 axis 时未能抛出错误(GH 54257)。

  • Series.map() 中的 Bug,当对空系列使用可调用对象时,返回的系列具有 object dtype。现在保留原始 dtype(GH 52384)。

  • Series.memory_usage() 中的 Bug,当 deep=True 时,针对对象系列抛出错误,并且返回值不正确,因为它未考虑 GC 校正(GH 51858)。

  • period_range() 中的错误,当未传递 freq 作为参数时,默认行为是不正确的(GH 53687

  • 修复了 pandas._libs.json__name__ 属性不正确的问题(GH 52898

Categorical

  • CategoricalIndex.remove_categories() 中的错误,有序类别将不会被维护(GH 53935

  • Series.astype() 中的错误,对于具有只读空值掩码的可空数组,使用 dtype="category" 时(GH 53658

  • Series.map() 中的错误,如果系列持有一个 Categorical,则 na_action 参数的值不会被使用(GH 22527

Datetimelike

  • DatetimeIndex.map() 中的 na_action="ignore" 现在按预期工作(GH 51644)

  • DatetimeIndex.slice_indexer() 现在对非单调索引引发 KeyError,如果切片边界中的任一边界不在索引中;此行为先前已被弃用,但处理不一致(GH 53983

  • DateOffset 中的错误,当将 DateOffset 对象乘以一个常数时,行为不一致(GH 47953

  • date_range() 中的错误,当 freq 是带有 nanosecondsDateOffset 时(GH 46877

  • to_datetime() 中的错误,将包含 PyArrow 时间戳的 SeriesDataFrame 转换为 numpy 日期时间(GH 52545

  • DatetimeArray.map()DatetimeIndex.map() 中的错误,提供的可调用函数是数组级别操作而不是元素级别操作(GH 51977

  • 在使用 PyArrow 支持的日期类型时,DataFrame.to_sql() 引发 ValueError 的 Bug (GH 53854)

  • Timestamp.date()Timestamp.isocalendar()Timestamp.timetuple()Timestamp.toordinal() 中存在的 Bug 返回了 Python 标准库 datetime 模块不支持的输入的错误结果 (GH 53668)

  • Timestamp.round() 在接近实现边界的值时返回错误结果而不是引发 OutOfBoundsDatetime 的 Bug (GH 51494)

  • 从日期时间或时间间隔标量构造 SeriesDataFrame 时总是推断纳秒分辨率而不是根据输入推断的 Bug (GH 52212)

  • 从不带日期的时间表示字符串构造 Timestamp 时推断出错误单位的 Bug (GH 54097)

  • 使用 ts_input=pd.NA 构造 Timestamp 时引发 TypeError 的 Bug (GH 45481)

  • 解析带有星期但没有日期的日期时间字符串的 Bug,例如 “2023 年 9 月 星期四”,错误地引发 AttributeError 而不是 ValueError (GH 52659)

  • 当 dtype 是时区感知日期时间且不是纳秒分辨率时,Series 的 repr 中存在的 Bug 引发 OutOfBoundsDatetime (GH 54623)

Timedelta

  • TimedeltaIndex 除法或乘法中存在的 Bug 导致 .freq 为 “0 天” 而不是 None (GH 51575)

  • Timedelta 中存在 Bug,对于 NumPy timedelta64 对象未能正确引发 ValueError (GH 52806)

  • to_timedelta() 中存在 Bug,将包含 pyarrow.durationSeriesDataFrame 转换为 NumPy timedelta64 (GH 54298)

  • Timedelta.__hash__() 中存在 Bug,在某些大值的秒分辨率上引发 OutOfBoundsTimedelta (GH 54037)

  • Timedelta.round() 中存在 Bug,对接近实现边界的值返回不正确的结果而不是引发 OutOfBoundsTimedelta (GH 51494)

  • TimedeltaIndex.map() 中存在 Bug,使用 na_action="ignore" (GH 51644)

  • arrays.TimedeltaArray.map()TimedeltaIndex.map() 中存在 Bug,提供的可调用函数以数组方式而不是元素方式操作 (GH 51977)

时区

  • infer_freq() 中存在 Bug,对于时区感知时间戳的 Series 引发 TypeError (GH 52456)

  • DatetimeTZDtype.base() 中存在 Bug,始终返回带纳秒分辨率的 NumPy dtype (GH 52705)

数值

  • RangeIndex 中存在 Bug,在被减数为数值时设置 step 不正确 (GH 53255)

  • Series.corr()Series.cov() 中存在 Bug,对于屏蔽的 dtype 引发 AttributeError (GH 51422)

  • 在调用 Series.kurt()Series.skew() 时存在 Bug,对于全零的 NumPy 数据返回 Python 类型而不是 NumPy 类型 (GH 53482)

  • Series.mean()DataFrame.mean() 中的 Bug,包含可以转换为数字的字符串的 object-dtype 值(例如“2”)返回不正确的数字结果;现在会引发 TypeError (GH 36703, GH 44008)

  • DataFrame.corrwith() 中的 Bug,对于 PyArrow-backed dtypes 引发 NotImplementedError (GH 52314)

  • DataFrame.size()Series.size() 中的 Bug,返回 64 位整数而不是 Python int (GH 52897)

  • DateFrame.dot() 中的 Bug,返回 ArrowDtype 数据的 object dtype (GH 53979)

  • Series.any()Series.all()DataFrame.any()DataFrame.all() 中的 Bug,bool_only 的默认值设置为 None 而不是 False;这一更改不应对用户产生影响(GH 53258)

  • Series.corr()Series.cov() 中的 Bug,对于蒙版 dtype 引发 AttributeError (GH 51422)

  • Series.median()DataFrame.median() 中的 Bug,包含可以转换为数字的字符串的 object-dtype 值(例如“2”)返回不正确的数字结果;现在会引发 TypeError (GH 34671)

  • Series.sum() 中的 Bug,将 dtype uint64 转换为 int64 (GH 53401)

转换

  • DataFrame.style.to_latex()DataFrame.style.to_html() 中的 Bug,如果 DataFrame 包含的整数位数比浮点双精度所能表示的位数更多,会出现问题(GH 52272)

  • array() 中的 Bug 在给定单位为“s”、“us”或“ms”的 datetime64timedelta64 dtype 时返回 NumpyExtensionArray 而不是 DatetimeArrayTimedeltaArrayGH 52859)

  • array() 中的 Bug 在给定空列表且无 dtype 时返回 NumpyExtensionArray 而不是 FloatingArrayGH 54371)

  • ArrowDtype.numpy_dtype() 中的 Bug 在非纳秒单位的 pyarrow.timestamppyarrow.duration 类型中返回纳秒单位(GH 51800)

  • DataFrame.__repr__() 中的 Bug 在某一列的 dtype 为 np.record 时错误地引发 TypeErrorGH 48526)

  • DataFrame.info() 中的 Bug 在设置 use_numba 时引发 ValueError 错误(GH 51922)

  • DataFrame.insert() 中的 Bug,如果 locnp.int64,会引发 TypeError 错误(GH 53193)

  • HDFStore.select() 中的 Bug 在存储和检索时丢失大整数的精度(GH 54186)

  • Series.astype() 中的 Bug 不支持 object_ 类型(GH 54251)

字符串

  • Series.str() 中的 Bug 在迭代时未引发 TypeError 错误(GH 54173)

  • DataFrame`` 的 repr` 中的 Bug 出现在字符串类型列中(GH 54797)

区间

  • target是只读数组时,IntervalIndex.get_indexer()IntervalIndex.get_indexer_nonunique()会引发异常(GH 53703)

  • 在删除时,IntervalDtype存在错误,对象可能被保留(GH 54184)

  • 在使用浮点step时,interval_range()存在错误,会产生不正确的区间(GH 54477)

索引

  • 在将DataFrame设置为重复列时,DataFrame.__setitem__()存在错误,会丢失 dtype(GH 53143)

  • 当使用布尔掩码和混合非数值 dtype 以及值不是NaN时,DataFrame.__setitem__()DataFrame.putmask()存在错误,错误地引发TypeErrorGH 53291)

  • 当将nan作为唯一元素时,DataFrame.iloc()存在错误(GH 52234)

  • 在将Series分配给object dtype Series的预定义索引时,Series.loc()存在错误,将Series转换为np.dnarrayGH 48933)

缺失

  • method"pad", "ffill", "bfill", 或"backfill"时,DataFrame.interpolate()存在错误,无法填充数据(GH 53898)

  • DataFrame为空时,DataFrame.interpolate()存在错误,忽略inplaceGH 53199)

  • 当包含 NaTDatetimeIndex 索引的 Series.idxmin()Series.idxmax()DataFrame.idxmin()DataFrame.idxmax() 中存在 bug,错误地返回 NaN 而不是 NaTGH 43587

  • 在无效的 downcast 关键字上失败未引发异常的 Series.interpolate()DataFrame.interpolate() 中存在 bug,该关键字只能为 None"infer"GH 53103

  • 具有复杂 dtype 的 Series.interpolate()DataFrame.interpolate() 中存在 bug,错误地未正确填充 NaN 条目(GH 53635

MultiIndex

  • MultiIndex.set_levels() 中,未保留 Categorical 的 dtype(GH 52125

  • 显示带有长元素的 MultiIndex 时存在 bug(GH 52960

I/O

  • 当给定非默认 Index 时,DataFrame.to_orc() 现在会引发 ValueErrorGH 51828

  • 当使用 SQLAlchemy 连接时,参数 name 留空时 DataFrame.to_sql() 现在会引发 ValueErrorGH 52675

  • json_normalize() 中的 bug 无法解析元数据字段列表类型(GH 37782

  • read_csv()中的错误,当parse_dates设置为列表或字典且engine="pyarrow"时会出错(GH 47961)

  • read_csv()中的错误,使用engine="pyarrow"时,指定dtypeindex_col时引发错误(GH 53229)

  • read_hdf()中的错误,在引发IndexError后未正确关闭存储(GH 52781)

  • read_html()中的错误,样式元素被读入 DataFrame 中(GH 52197)

  • read_html()中的错误,尾部文本与包含display:none样式的元素一起被移除(GH 51629)

  • read_sql_table()中的错误,在读取视图时引发异常(GH 52969)

  • read_sql()中的错误,在读取具有相同列名的多个时区感知列时出错(GH 44421)

  • read_xml()中的错误,剥离字符串数据中的空格(GH 53811)

  • DataFrame.to_html()中的错误,在多级索引列的情况下错误应用colspaceGH 53885)

  • DataFrame.to_html()中的错误,当空的DataFrame具有复杂 dtype 时会引发ValueErrorGH 54167)

  • DataFrame.to_json()中的错误,DateTimeArray/DateTimeIndex具有非纳秒精度时无法正确序列化(GH 53686)

  • 写入和读取空的 Stata dta 文件时出现的错误,dtype 信息丢失(GH 46240)

  • bz2视为硬性要求的错误(GH 53857)

Period

  • PeriodDtype 构造函数中的 Bug 在没有传递参数或传递 None 时未能引发 TypeErrorGH 27388

  • PeriodDtype 构造函数中,不正确地对不同的 DateOffset freq 输入返回相同的 normalize 的 Bug(GH 24121

  • 在传递无效类型时,PeriodDtype 构造函数引发 ValueError 而不是 TypeError 的 Bug(GH 51790

  • 在删除时保持对象的 Bug(GH 54184

  • read_csv() 中的 Bug 未将空字符串处理为空值,在使用 engine="pyarrow" 时出现此问题(GH 52087

  • 使用 engine="pyarrow" 时,read_csv() 返回 object dtype 列而不是所有列都为 null 时返回 float64 dtype 列的 Bug(GH 52087

  • Period.now() 中的 Bug 不接受 freq 参数作为关键字参数(GH 53369

  • na_action="ignore" 下的 PeriodIndex.map() 中的 Bug(GH 51644

  • arrays.PeriodArray.map()PeriodIndex.map() 中,提供的可调用函数以数组方式而不是元素方式操作的 Bug(GH 51977

  • 不正确地允许使用 CustomBusinessDay 频率构造 PeriodPeriodDtype 中的 Bug;应改用 BusinessDayGH 52534

绘图

  • 在使用 color=None 调用 Series.plot() 时出现的 Bug(GH 51953

  • 在使用 c="b" 调用 DataFrame.plot.scatter() 时,修复了 UserWarning(GH 53908

Groupby/resample/rolling

  • DataFrameGroupBy.idxmin()SeriesGroupBy.idxmin()DataFrameGroupBy.idxmax()SeriesGroupBy.idxmax() 在空的 DataFrameGroupBy 或 SeriesGroupBy 上使用时返回错误的数据类型(GH 51423)。

  • 在可空数据类型上使用 DataFrame.groupby.rank() 时,当传递 na_option="bottom"na_option="top" 时存在 Bug(GH 54206)。

  • DataFrame.resample()Series.resample() 中,当在 TimedeltaIndex 上重采样时,不正确地允许非固定的 freqGH 51896)。

  • DataFrame.resample()Series.resample() 在重采样空数据时丢失时区信息(GH 53664)。

  • DataFrame.resample()Series.resample() 中,当值超出轴范围时,origin 在重采样中没有效果(GH 53662)。

  • 在指定 min_periods=0 时,加权滚动聚合存在 Bug(GH 51449)。

  • DataFrame.groupby()Series.groupby() 中的 Bug,当分组后的 SeriesDataFrame 的索引是 DatetimeIndexTimedeltaIndexPeriodIndex 时,且 groupby 方法的第一个参数是函数时,该函数会作用于整个索引而不是索引的每个元素 (GH 51979)

  • DataFrameGroupBy.agg() 中的 Bug,列表不遵守 as_index=False (GH 52849)

  • DataFrameGroupBy.apply() 中的 Bug,在对分组后的输入 DataFrame 进行子集化后作为 DataFrame 应用时,如果给定的可调用函数返回的 Series 的索引不完全相同,会引发错误 (GH 52444)

  • DataFrameGroupBy.apply() 中的 Bug,在选择多列并提供返回 np.ndarray 结果的函数时,会引发 TypeError (GH 18930)

  • DataFrameGroupBy.groups()SeriesGroupBy.groups() 中的 Bug,在具有日期时间键和另一个键的情况下,产生了不正确数量的分组键 (GH 51158)

  • DataFrameGroupBy.quantile()SeriesGroupBy.quantile()中的错误可能会在sort=False的情况下隐式对结果索引进行排序(GH 53009)

  • SeriesGroupBy.size()中的错误,对于具有ArrowDtype或掩码 dtype(例如Int64)的数据,dtype 将为np.int64GH 53831)

  • DataFrame.groupby()中的错误,在结果 groupby 对象上进行列选择时,当通过由单个元素组成的列表进行分组时,未返回名称为元组的情况(GH 53500)

  • DataFrameGroupBy.var()SeriesGroupBy.var()中的错误,在使用 datetime64、timedelta64 或PeriodDtype值调用时未引发TypeErrorGH 52128, GH 53045)

  • DataFrameGroupBy.resample()中的错误,使用kind="period"时引发AttributeErrorGH 24103)

  • Resampler.ohlc()中的错误,当返回空对象时返回一个Series而不是空的DataFrameGH 42902)

  • Bug in SeriesGroupBy.count()DataFrameGroupBy.count() 当数据具有 ArrowDtype 或掩码类型(例如 Int64)时,dtype 为 np.int64GH 53831

  • Bug in SeriesGroupBy.nth()DataFrameGroupBy.nth() 在使用 dropna="any"dropna="all" 进行列选择后不会对列进行子集化(GH 53518

  • Bug in SeriesGroupBy.nth()DataFrameGroupBy.nth() 在使用 dropna="any"dropna="all" 进行列选择后引发错误,导致行被丢弃(GH 53518

  • Bug in SeriesGroupBy.sum()DataFrameGroupBy.sum()np.inf + np.inf(-np.inf) + (-np.inf) 分别求和为 np.nan 而不是 np.inf-np.infGH 53606

  • Bug in Series.groupby() 将一个带有 DatetimeIndex 索引的分组 Series 和一个月份作为名称的 Series 给定给 by 参数时引发错误(GH 48509

重塑

  • Bug in concat() 当一个列具有 pa.null() 类型时,强制转换为 object 类型(GH 53702

  • crosstab()dropna=False 时,结果中不会保留 np.nanGH 10772

  • melt() 存在错误,其中 variable 列将丢失扩展的 dtype(GH 54297

  • merge_asof() 对于扩展 dtypes 引发 KeyErrorGH 52904

  • merge_asof() 对于由只读 ndarrays 支持的数据引发 ValueErrorGH 53513

  • merge_asof()left_index=Trueright_index=True 时,如果索引 dtypes 不匹配,则在某些情况下给出不正确的结果,而不是引发 MergeErrorGH 53870

  • merge() 在整数 ExtensionDtype 和浮点数 NumPy dtype 上合并时引发 TypeErrorGH 46178

  • DataFrame.agg()Series.agg() 在非唯一列上存在的错误,当传入 dist 类似参数时,返回的类型不正确(GH 51099

  • DataFrame.combine_first() 如果 other 为空,则会忽略其他列(GH 53792

  • DataFrame.idxmin()DataFrame.idxmax() 存在错误,其中轴的 dtype 将在空框架中丢失(GH 53265

  • DataFrame.merge() 在具有单个级别的 MultiIndex 时未正确合并(GH 52331

  • DataFrame.stack() 当列是 MultiIndex 且帧包含混合 dtype 时,将丢失扩展 dtypes(GH 45740

  • DataFrame.stack() 中的 Bug,按字典顺序对列进行排序 (GH 53786)

  • DataFrame.transpose() 中的 Bug,推断对象列的 dtype (GH 51546)

  • Series.combine_first() 中的 Bug,将 int64 dtype 转换为 float64 并在非常大的整数上失去精度 (GH 51764)

  • 在连接空的 DataFrame 对象时的 Bug,连接的索引会是 RangeIndex 而不是连接的索引类型 (GH 52777)

稀疏

  • SparseDtype 构造函数中的 Bug,在其子类型的不兼容 dtype 时未能引发 TypeError (GH 53160)

  • arrays.SparseArray.map()中的 Bug 允许将填充值包含在稀疏值中 (GH 52095)

ExtensionArray

  • ArrowStringArray 构造函数中的 Bug,在字符串的字典类型上引发 ValueError (GH 54074)

  • DataFrame 构造函数中的 Bug,在字典中给定扩展 dtype 的 Series 时未进行复制 (GH 53744)

  • ArrowExtensionArray 中的 Bug,将 pandas 非纳秒时间对象从非零值转换为零值 (GH 53171)

  • Series.quantile() 中的 Bug,对 PyArrow 时间类型引发 ArrowInvalid (GH 52678)

  • Series.rank() 中的 Bug,在具有 Float64 dtype 的小值中返回错误的顺序 (GH 52471)

  • 在具有 NA 值的布尔 ArrowDtype 中的 Series.unique() 存在 Bug(GH 54667

  • 在非纳秒 dtype 中的 __iter__()__getitem__() 中存在 Bug,返回 Python datetime 和 timedelta 对象(GH 53326

  • 在返回具有多个块的 pyarrow.dictionary 类型的 pyarrow.chunked_arrayfactorize() 中存在 Bug,返回不正确的唯一值(GH 54844

  • ExtensionArray 子类传递给 dtype 关键字时存在 Bug。现在会引发 UserWarning,以鼓励传递一个实例(GH 31356GH 54592

  • 当列具有带有 pyarrow.ExtensionDtypeArrowDtype 时,DataFrame repr 不起作用的 Bug(GH 54063

  • __from_arrow__ 方法在被遮蔽的 ExtensionDtypes(例如 Float64DtypeBooleanDtype)中存在的 Bug,不接受类型为 pyarrow.null() 的 PyArrow 数组(GH 52223

Styler

  • Styler._copy() 中存在 Bug,调用 Styler 的子类中重写的方法(GH 52728

元数据

  • DataFrame.max()DataFrame.min()DataFrame.prod()DataFrame.mean()Series.mode()DataFrame.median()DataFrame.sem()DataFrame.skew()DataFrame.kurt() 中修复了元数据传播(GH 28283

  • DataFrame.squeeze()DataFrame.describe()中修复了元数据传播(GH 28283

  • DataFrame.std()中修复了元数据传播(GH 28283

其他

  • FloatingArray.__contains__中的错误,当存在NaN值时,NaN项错误地返回FalseGH 52840

  • DataFrameSeries中的错误,在存在NaN值时,对复杂 dtype 数据引发异常(GH 53627

  • DatetimeIndex中的错误,当带有时间的索引传递时,repr不打印时间为午夜和非基于日期的频率(GH 53470

  • testing.assert_frame_equal()testing.assert_series_equal()中的错误,现在对两个不相等的集合抛出断言错误(GH 51727

  • testing.assert_frame_equal()中的错误,即使要求不检查索引类型,也会检查类别 dtype(GH 52126

  • api.interchange.from_dataframe()中的错误,未遵守allow_copy参数(GH 54322

  • api.interchange.from_dataframe()中的错误,在从包含空值的非 pandas tz-aware 数据进行交换时引发异常(GH 54287

  • api.interchange.from_dataframe()中的错误,当转换空的 DataFrame 对象时(GH 53155

  • from_dummies()中存在的一个 bug,结果 Index 与原始 Index 不匹配 (GH 54300)

  • from_dummies()中存在的一个 bug,结果数据始终为 object dtype 而不是列的 dtype (GH 54300)

  • 在空组返回 np.nan 而不是相应的 ExtensionArray NA 值的情况下,在 DataFrameGroupBy.first()DataFrameGroupBy.last()SeriesGroupBy.first()SeriesGroupBy.last() 中存在的一个 bug (GH 39098)

  • 在将 ints 的均值转换回 int 时,DataFrame.pivot_table() 中存在的一个 bug (GH 16676)

  • DataFrame.reindex()中存在的一个 bug,应该用 ExtensionDtype 推断 fill_value,但错误地推断为 object dtype (GH 52586)

  • 当在具有单个 ExtensionDtype 列的 DataFrame 上使用 axis=1 时,DataFrame.shift() 中存在的一个 bug 会导致结果不正确 (GH 53832)

  • 当传递一个 key 时,Index.sort_values()中存在的一个 bug (GH 52764)

  • Bug in Series.align(), DataFrame.align(), Series.reindex(), DataFrame.reindex(), Series.interpolate(), DataFrame.interpolate() 在使用method=”asfreq”时错误地未引发异常(GH 53620)

  • Bug in Series.argsort() 当传递无效的axis时未引发异常(GH 54257)

  • Bug in Series.map() 当对空系列传递可调用对象时,返回的系列的dtypeobject。现在保持原始dtypeGH 52384)

  • Bug in Series.memory_usage()deep=True时,对包含对象的系列抛出错误,并且返回值不正确,因为未考虑 GC 修正(GH 51858)

  • Bug in period_range() 当未传递freq参数时,默认行为是不正确的(GH 53687)

  • 修复了pandas._libs.json__name__属性不正确的问题(GH 52898)

贡献者

本次发布共有 266 人贡献了补丁。名字后带有“+”的人第一次贡献了补丁。

  • AG +

  • Aarni Koskela

  • Adrian D’Alessandro +

  • Adrien RUAULT +

  • Ahmad +

  • Aidos Kanapyanov +

  • Alex Malins

  • Alexander Seiler +

  • Ali Asgar +

  • Allison Kwan

  • Amanda Bizzinotto +

  • Andres Algaba +

  • Angela Seo +

  • Anirudh Hegde +

  • Antony Evmorfopoulos +

  • Anushka Bishnoi

  • ArnaudChanoine +

  • Artem Vorobyev +

  • Arya Sarkar +

  • Ashwin Srinath

  • Austin Au-Yeung +

  • Austin Burnett +

  • Bear +

  • Ben Mangold +

  • Bernardo Gameiro +

  • Boyd Kane +

  • Brayan Alexander Muñoz B +

  • Brock

  • Chetan0402 +

  • Chris Carini

  • ChristofKaufmann

  • Clark-W +

  • Conrad Mcgee Stocks

  • Corrie Bartelheimer +

  • Coulton Theuer +

  • D067751 +

  • Daniel Isaac

  • Daniele Nicolodi +

  • David Samuel +

  • David Seifert +

  • Dea Leon +

  • Dea María Léon

  • Deepyaman Datta

  • Denis Sapozhnikov +

  • Dharani Akurathi +

  • DimiGrammatikakis +

  • Dirk Ulbricht +

  • Dmitry Shemetov +

  • Dominik Berger

  • Efkan S. Goktepe +

  • Ege Özgüroğlu

  • Eli Schwartz

  • Erdi +

  • Fabrizio Primerano +

  • Facundo Batista +

  • Fangchen Li

  • Felipe Maion +

  • Francis +

  • Future Programmer +

  • Gabriel Kabbe +

  • Gaétan Ramet +

  • Gianluca Ficarelli

  • Godwill Agbehonou +

  • Guillaume Lemaitre

  • Guo Ci

  • Gustavo Vargas +

  • Hamidreza Sanaee +

  • HappyHorse +

  • Harald Husum +

  • Hugo van Kemenade

  • Ido Ronen +

  • Irv Lustig

  • JHM Darbyshire

  • JHM Darbyshire (iMac)

  • JJ +

  • Jarrod Millman

  • Jay +

  • Jeff Reback

  • Jessica Greene +

  • Jiawei Zhang +

  • Jinli Xiao +

  • Joanna Ge +

  • Jona Sassenhagen +

  • Jonas Haag

  • Joris Van den Bossche

  • Joshua Shew +

  • Julian Badillo

  • Julian Ortiz +

  • Julien Palard +

  • Justin Tyson +

  • Justus Magin

  • Kabiir Krishna +

  • Kang Su Min

  • Ketu Patel +

  • Kevin +

  • Kevin Anderson

  • Kevin Jan Anker

  • Kevin Klein +

  • Kevin Sheppard

  • Kostya Farber

  • LM +

  • Lars Lien Ankile +

  • Lawrence Mitchell

  • Liwei Cai +

  • Loic Diridollou

  • Luciana Solorzano +

  • Luke Manley

  • Lumberbot (aka Jack)

  • Marat Kopytjuk +

  • Marc Garcia

  • Marco Edward Gorelli

  • MarcoGorelli

  • Maria Telenczuk +

  • MarvinGravert +

  • Mateusz Sokół +

  • Matt Richards

  • Matthew Barber +

  • Matthew Roeschke

  • Matus Valo +

  • Mia Reimer +

  • Michael Terry +

  • Michael Tiemann +

  • Milad Maani Jou +

  • Miles Cranmer +

  • MirijaH +

  • Miyuu +

  • Natalia Mokeeva

  • Nathan Goldbaum +

  • Nicklaus Roach +

  • Nicolas Camenisch +

  • Nikolay Boev +

  • Nirav

  • Nishu Choudhary

  • Noa Tamir

  • Noy Hanan +

  • Numan +

  • Numan Ijaz +

  • Omar Elbaz +

  • Pandas Development Team

  • Parfait Gasana

  • Parthi

  • Patrick Hoefler

  • Patrick Schleiter +

  • Pawel Kranzberg +

  • Philip

  • Philip Meier +

  • Pranav Saibhushan Ravuri

  • PrathumP +

  • Rahul Siloniya +

  • Rajasvi Vinayak +

  • Rajat Subhra Mukherjee +

  • Ralf Gommers

  • RaphSku

  • Rebecca Chen +

  • Renato Cotrim Maciel +

  • Reza (Milad) Maanijou +

  • Richard Shadrach

  • Rithik Reddy +

  • Robert Luce +

  • Ronalido +

  • Rylie Wei +

  • SOUMYADIP MAL +

  • Sanjith Chockan +

  • Sayed Qaiser Ali +

  • Scott Harp +

  • Se +

  • Shashwat Agrawal

  • Simar Bassi +

  • Simon Brugman +

  • Simon Hawkins

  • Simon Høxbro Hansen

  • Snorf Yang +

  • Sortofamudkip +

  • Stefan Krawczyk

  • Stefanie Molin

  • Stefanie Senger

  • Stelios Petrakis +

  • Stijn Van Hoey

  • Sven

  • Sylvain MARIE

  • Sylvain Marié

  • Terji Petersen

  • Thierry Moisan

  • Thomas

  • Thomas A Caswell

  • Thomas Grainger

  • Thomas Li

  • Thomas Vranken +

  • Tianye Song +

  • Tim Hoffmann

  • Tim Loderhose +

  • Tim Swast

  • Timon Jurschitsch +

  • Tolker-KU +

  • Tomas Pavlik +

  • Toroi +

  • Torsten Wörtwein

  • Travis Gibbs +

  • Umberto Fasci +

  • Valerii +

  • VanMyHu +

  • Victor Momodu +

  • Vijay Vaidyanathan +

  • VomV +

  • William Andrea

  • William Ayd

  • Wolf Behrenhoff +

  • Xiao Yuan

  • Yao Xiao

  • Yasin Tatar

  • Yaxin Li +

  • Yi Wei +

  • Yulia +

  • Yusharth Singh +

  • Zach Breger +

  • Zhengbo Wang

  • abokey1 +

  • ahmad2901 +

  • assafam +

  • auderson

  • august-tengland +

  • bunardsheng +

  • cmmck +

  • cnguyen-03 +

  • coco +

  • dependabot[bot]

  • giplessis +

  • github-actions[bot]

  • gmaiwald +

  • gmollard +

  • jbrockmendel

  • kathleenhang

  • kevx82 +

  • lia2710 +

  • liang3zy22 +

  • ltartaro +

  • lusolorz +

  • m-ganko +

  • mKlepsch +

  • mattkeanny +

  • mrastgoo +

  • nabdoni +

  • omar-elbaz +

  • paulreece +

  • penelopeysm +

  • potap75 +

  • pre-commit-ci[bot] +

  • raanasn +

  • raj-thapa +

  • ramvikrams +

  • rebecca-palmer

  • reddyrg1 +

  • rmhowe425 +

  • segatrade +

  • shteken +

  • sweisss +

  • taytzehao

  • tntmatthews +

  • tpaxman +

  • tzehaoo +

  • v-mcoutinho +

  • wcgonzal +

  • yonashub

  • yusharth +

  • Ádám Lippai

  • Štěpán Műller +

posted @ 2024-06-26 10:34  绝不原创的飞龙  阅读(14)  评论(0编辑  收藏  举报