0.23.1 版本的新内容(2018年6月12日)#
这是 0.23.x 系列中的一个小错误修复版本,包括一些小的回归修复和错误修复。我们建议所有用户升级到此版本。
警告
自2019年1月1日起,pandas 功能版本将仅支持 Python 3。更多信息请参见 Dropping Python 2.7。
v0.23.1 中的新内容
修复回归问题#
将系列与 datetime.date 进行比较
我们恢复了 0.23.0 版本中对持有日期时间的 Series 和 datetime.date 对象进行比较的更改 (GH 21152)。在 pandas 0.22 及更早版本中,比较持有日期时间的 Series 和 datetime.date 对象时,会将 datetime.date 强制转换为日期时间后再进行比较。这与 Python、NumPy 和 DatetimeIndex 不一致,后者从不认为日期时间和 datetime.date 对象相等。
在 0.23.0 版本中,我们统一了 DatetimeIndex 和 Series 之间的操作,并且在没有警告的情况下更改了日期时间 Series 和 datetime.date 之间的比较。
我们暂时恢复了 0.22.0 的行为,因此日期时间和日期可能再次比较相等,但在未来的版本中将恢复 0.23.0 的行为。
总结来说,以下是 0.22.0、0.23.0、0.23.1 版本中的行为:
# 0.22.0... Silently coerce the datetime.date
>>> import datetime
>>> pd.Series(pd.date_range('2017', periods=2)) == datetime.date(2017, 1, 1)
0 True
1 False
dtype: bool
# 0.23.0... Do not coerce the datetime.date
>>> pd.Series(pd.date_range('2017', periods=2)) == datetime.date(2017, 1, 1)
0 False
1 False
dtype: bool
# 0.23.1... Coerce the datetime.date with a warning
>>> pd.Series(pd.date_range('2017', periods=2)) == datetime.date(2017, 1, 1)
/bin/python:1: FutureWarning: Comparing Series of datetimes with 'datetime.date'. Currently, the
'datetime.date' is coerced to a datetime. In the future pandas will
not coerce, and the values not compare equal to the 'datetime.date'.
To retain the current behavior, convert the 'datetime.date' to a
datetime with 'pd.Timestamp'.
#!/bin/python3
0 True
1 False
dtype: bool
此外,将来排序比较将引发 TypeError 。
其他修复
在时区感知数据的情况下,修复了
DatetimeIndex.date和DatetimeIndex.time属性的固定回归:DatetimeIndex.time返回了 tz-aware 时间而不是 tz-naive (GH 21267),并且当输入日期具有非UTC时区时,DatetimeIndex.date返回了不正确的日期 (GH 21230)。修复了在 JSON 的嵌套级别中调用包含
None值的pandas.io.json.json_normalize()时的回归问题,并且不会删除值为None的键 (GH 21158, GH 21356)。阻止 pandas 在 -OO 优化下可导入的错误 (GH 21071)
Categorical.fillna()中的错误在value是可迭代且value是可迭代时,不正确地引发TypeError(GH 21097, GH 19788)修复了在传递
dtype=str时,构造函数将None等 NA 值强制转换为字符串的回归问题 (GH 21083)在
pivot_table()中的回归,其中对于枢轴的index具有缺失值的有序Categorical会导致对齐错误的结果 (GH 21133)修复了在布尔索引/列上合并的回归问题 (GH 21119)。
性能提升#
错误修复#
分组/重采样/滚动
在
DataFrame.agg()中的一个错误,当对一个具有重复列名的DataFrame应用多个聚合函数时会导致堆栈溢出 (GH 21063)在
GroupBy.ffill()和GroupBy.bfill()中的一个错误,由于实现中使用了非稳定排序,导致分组内的填充并不总是按预期应用 (GH 21207)在
GroupBy.rank()中的一个错误,当指定method='dense'和pct=True时,结果没有缩放到100%。pandas.DataFrame.rolling()和pandas.Series.rolling()中的错误,错误地接受了一个0窗口大小而不是引发 (GH 21286)
特定数据类型
在
Series.str.replace()方法中的错误,该方法在 Python 3.5.2 上抛出TypeError(GH 21078)在
pandas.testing.assert_index_equal()中的一个错误,当比较两个带有参数check_categorical=False的CategoricalIndex对象时,错误地引发了AssertionError(GH 19776)
稀疏
在
SparseArray.shape中的错误,之前只返回了SparseArray.sp_values的形状 (GH 21126)
索引
在
Series.reset_index()中的错误,当使用无效的级别名称时未引发适当的错误 (GH 20925)当
start/periods或end/periods与浮点数start或end一起指定时,interval_range()中的错误 (GH 21161)在
MultiIndex.set_names()中的错误,当MultiIndex的nlevels == 1时引发错误 (GH 21149)IntervalIndex构造函数中的错误,其中从分类数据创建IntervalIndex未完全支持 (GH 21243, GH 21253)在
MultiIndex.sort_index()中的一个错误,该错误不能保证在level=1时正确排序;这也会在特定的DataFrame.stack()操作中导致数据错位 (GH 20994, GH 20945, GH 21052)
绘图
新的关键字(sharex, sharey)用于在通过 pandas.DataFrame().groupby().boxplot() 生成的子图中开启/关闭 x/y 轴的共享 (GH 20968)
I/O
在指定
compression='zip'的 IO 方法中的错误,产生了未压缩的 zip 存档 (GH 17778, GH 21144)在
DataFrame.to_stata()中的错误,阻止了将 DataFrame 导出到缓冲区和大多数类文件对象 (GH 21041)read_stata()和StataReader中的一个错误,该错误在从 Stata 14 文件(dta 版本 118)读取时未能在 Python 3 上正确解码 utf-8 字符串(GH 21244)IO JSON 中的
read_json()在以orient='table'读取空的 JSON 模式并返回DataFrame时导致了一个错误 (GH 21287)
重塑
其他
贡献者#
总共有30个人为这次发布贡献了补丁。名字后面有“+”的人第一次贡献了补丁。
Adam J. Stewart
Adam Kim +
Aly Sivji
Chalmer Lowe +
Damini Satya +
Dr. Irv
Gabe Fernando +
Giftlin Rajaiah
Jeff Reback
Jeremy Schendel +
Joris Van den Bossche
Kalyan Gokhale +
Kevin Sheppard
Matthew Roeschke
Max Kanter +
Ming Li
Pyry Kovanen +
Stefano Cianciulli
Tom Augspurger
Uddeshya Singh +
Wenhuan
William Ayd
chris-b1
gfyoung
h-vetinari
nprad +
ssikdar1 +
tmnhat2001
topper-123
zertrin +