0.23.1中的新特性(2018年6月12日)#
这是0.23.x系列中的一个较小的错误修复版本,包括一些小的回归修复和错误修复。我们建议所有用户升级到此版本。
警告
从2019年1月1日开始,Pandas功能发布将只支持Python3。看见 Dropping Python 2.7 想要更多。
固定回归#
将Series与DateTim.Date进行比较
我们已将0.23.0更改恢复为比较 Series 保存日期时间和一个 datetime.date 对象 (GH21152 )。在Pandas0.22和更早版本中,将保存日期时间的序列与 datetime.date 对象会迫使 datetime.date 设置为日期时间,然后再进行比较。这与Python、NumPy和 DatetimeIndex ,它从不考虑日期时间和 datetime.date 平起平坐。
在0.23.0中,我们统一了DatetimeIndex和Series之间的操作,并在此过程中更改了一系列DateTime和 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感知时间,而不是Tz-naive (GH21267 )和DatetimeIndex.date当输入日期具有非UTC时区时,返回错误的日期 (GH21230 )。Fixed regression in
pandas.io.json.json_normalize()when called withNonevalues in nested levels in JSON, and to not drop keys with value asNone(GH21158, GH21356).通过-OO优化阻止Pandas进口的错误 (GH21071 )
窃听
Categorical.fillna()错误地引发TypeError什么时候value各个类别是可迭代的,并且value是一个可迭代的 (GH21097 , GH19788 )Fixed regression in constructors coercing NA values like
Noneto strings when passingdtype=str(GH21083)回归到
pivot_table()在那里订购了一个Categorical缺少透视表的值index将产生未对齐的结果 (GH21133 )修复了对布尔索引/列进行合并时的回归 (GH21119 )。
性能改进#
错误修复#
Groupby/resample/rolling
窃听
DataFrame.agg()其中,将多个聚合函数应用于DataFrame使用重复的列名将导致堆栈溢出 (GH21063 )窃听
pandas.core.groupby.GroupBy.ffill()和pandas.core.groupby.GroupBy.bfill()其中,由于实现使用了非稳定排序,分组中的填充不会始终按预期应用 (GH21207 )窃听
pandas.core.groupby.GroupBy.rank()指定时,结果不会缩放到100%method='dense'和pct=True窃听
pandas.DataFrame.rolling()和pandas.Series.rolling()它错误地接受了窗口大小为0,而不是提高 (GH21286 )
Data-type specific
窃听
Series.str.replace()该方法在哪里引发TypeError在Python3.5.2上 (GH21078 )Bug in
pandas.testing.assert_index_equal()which raisedAssertionErrorincorrectly, when comparing twoCategoricalIndexobjects with paramcheck_categorical=False(GH19776)
Sparse
Bug in
SparseArray.shapewhich previously only returned the shapeSparseArray.sp_values(GH21126)
Indexing
窃听
Series.reset_index()在适当的情况下,未引发级别名称无效的错误 (GH20925 )Bug in
interval_range()whenstart/periodsorend/periodsare specified with floatstartorend(GH21161)Bug in
MultiIndex.set_names()where error raised for aMultiIndexwithnlevels == 1(GH21149)窃听
IntervalIndex构造函数,其中创建IntervalIndex不完全支持从分类数据 (GH21243 , GH21253 )窃听
MultiIndex.sort_index()不能保证正确排序的level=1;这也特别会导致数据未对齐DataFrame.stack()运营 (GH20994 , GH20945 , GH21052 )
Plotting
新的关键字(Sharx、Shary),用于打开/关闭由Pandas.DataFrame().groupby().boxlot()生成的子图共享x/y轴 (GH20968 )
I/O
IO方法中指定的错误
compression='zip'它产生了未压缩的Zip档案 (GH17778 , GH21144 )窃听
DataFrame.to_stata()阻止将DataFrame导出到缓冲区和大多数类似文件的对象 (GH21041 )窃听
read_stata()和StataReader它无法从Stata 14文件(DTA版本118)中正确解码Python3上的UTF-8字符串 (GH21244 )IO JSON中的错误
read_json()使用读取空JSON架构orient='table'返回到DataFrame导致错误 (GH21287 )
Reshaping
Other
贡献者#
共有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 +