1.0.2 版本新特性(2020 年 3 月 12 日)#
以下是 pandas 1.0.2 的变更。有关包含其他 pandas 版本的完整变更日志,请参阅发行说明。
已修复的回归问题#
Groupby
已修复
DataFrameGroupBy.agg()
和SeriesGroupBy.agg()
在带有MultiIndex
列和自定义函数的数据帧上失败的回归问题 (GH 31777)已修复
groupby(..).rolling(..).apply()
(RollingGroupby
) 中raw
参数被忽略的回归问题 (GH 31754)已修复
rolling(..).corr()
在使用时间偏移时出现的回归问题 (GH 31789)已修复
groupby(..).nunique()
在存在NaN
值时会修改原始值的回归问题 (GH 31950)已修复
DataFrame.groupby
在内部操作中引发ValueError
的回归问题 (GH 31802)已修复
DataFrameGroupBy.agg()
和SeriesGroupBy.agg()
在空输入上额外调用用户提供的函数一次的回归问题 (GH 31760)
输入/输出 (I/O)
已修复
read_csv()
在某些文件类对象中无法识别encoding
选项的回归问题 (GH 31819)已修复
DataFrame.to_excel()
在传递columns
关键字参数时出现的回归问题 (GH 31677)已修复
read_pickle()
在读取带有MultiIndex
列的 py27 pickle 文件时引发UnicodeDecodeError
的回归问题 (GH 31988)。
重新索引/对齐
已修复
Series.align()
在other
是DataFrame
且method
不为None
时出现的回归问题 (GH 31785)已修复
DataFrame.reindex()
和Series.reindex()
在使用(时区感知)索引和method=nearest
进行重新索引时出现的回归问题 (GH 26683)已修复
DataFrame.reindex_like()
在DataFrame
子类上引发AssertionError
的回归问题 (GH 31925)
其他
已修复在
DatetimeIndex
或TimedeltaIndex
上进行连接时,在简单情况下保留freq
的回归问题 (GH 32166)已修复
Series.shift()
在datetime64
dtype 下传递整数fill_value
时出现的回归问题 (GH 32591)
使用可空布尔数组进行索引#
此前,使用包含 NA
的可空布尔数组进行索引会引发 ValueError
,但现在允许这样做,且 NA
被视为 False
。(GH 31503)
In [1]: s = pd.Series([1, 2, 3, 4])
In [2]: mask = pd.array([True, True, False, None], dtype="boolean")
In [3]: s
Out[3]:
0 1
1 2
2 3
3 4
Length: 4, dtype: int64
In [4]: mask
Out[4]:
<BooleanArray>
[True, True, False, <NA>]
Length: 4, dtype: boolean
pandas 1.0.0-1.0.1
>>> s[mask]
Traceback (most recent call last):
...
ValueError: cannot mask with array containing NA / NaN values
pandas 1.0.2
In [5]: s[mask]
Out[5]:
0 1
1 2
Length: 2, dtype: int64
Bug 修复#
日期时间相关类型
修复了
Series.astype()
在处理时区-naive 和时区-aware 的datetime64
dtype 时不进行复制的 Bug (GH 32490)修复了
to_datetime()
在传入pd.NA
时会引发异常的 Bug (GH 32213)
类别型 (Categorical)
修复了
Categorical.from_codes()
在传入可空整数代码时错误地引发ValueError
的 Bug。(GH 31779)修复了
Categorical()
构造函数在给定包含pd.NA
的 numpy 数组时会引发TypeError
的 Bug。(GH 31927)修复了
Categorical
在使用列表状to_replace
调用Series.replace()
时会忽略或崩溃的 Bug (GH 31720)
输入/输出 (I/O)
在
DataFrame.to_json()
中使用pd.NA
现在会正确地输出 null 值,而不是空对象 (GH 31615)修复了
pandas.json_normalize()
在 meta 路径中的值不可迭代时的 Bug (GH 31507)修复了
pandas.NA
的 pickling 问题。此前会返回一个新对象,这破坏了依赖于NA
为单例的计算 (GH 31847)修复了使用可空无符号整数 dtype 进行 parquet 往返转换时的 Bug (GH 31896)。
实验性 dtype
修复了
DataFrame.convert_dtypes()
对于已经使用"string"
dtype 的列存在的 Bug (GH 31731)。修复了
DataFrame.convert_dtypes()
对于混合了整数和字符串的 series 存在的 Bug (GH 32117)修复了
DataFrame.convert_dtypes()
中BooleanDtype
列被转换为Int64
的 Bug (GH 32287)修复了使用带有 string dtype 的切片索引器设置值时的 Bug (GH 31772)
修复了
DataFrameGroupBy.first()
,SeriesGroupBy.first()
,DataFrameGroupBy.last()
和SeriesGroupBy.last()
在分组中包含 object dtype 列的pd.NA 值时会引发
TypeError
的 Bug (GH 32123)修复了
DataFrameGroupBy.mean()
,DataFrameGroupBy.median()
,DataFrameGroupBy.var()
和DataFrameGroupBy.std()
在Int64
dtype 列上会引发TypeError
的 Bug (GH 32219)
字符串
在
Series.str.repeat()
中使用pd.NA
现在会正确地输出 null 值,而不是对向量输入引发错误 (GH 31632)
滚动计算 (Rolling)
修复了在递减时间索引上使用可变窗口(由时间范围定义)进行滚动计算操作的 Bug (GH 32385)。
贡献者#
共有 25 位贡献者为本次版本发布贡献了补丁。名字旁边带有“+”的人是首次贡献补丁。
Anna Daglis +
Daniel Saxton
Irv Lustig
Jan Škoda
Joris Van den Bossche
Justin Zheng
Kaiqi Dong
Kendall Masse
Marco Gorelli
Matthew Roeschke
MeeseeksMachine
MomIsBestFriend
Pandas 开发团队
Pedro Reys +
Prakhar Pandey
Robert de Vries +
Rushabh Vasani
Simon Hawkins
Stijn Van Hoey
Terji Petersen
Tom Augspurger
William Ayd
alimcmaster1
gfyoung
jbrockmendel