版本 0.21.1 (2017年12月12日)#

这是 0.21.x 系列中的一个小型错误修复版本,包含一些小的回归修复、错误修复和性能改进。我们建议所有用户升级到此版本。

主要亮点包括

  • 临时恢复 matplotlib 日期时间绘图功能。这应该能解决那些隐式依赖 pandas 使用 matplotlib 绘制日期时间的用户的问题。详见 此处

  • 对 0.21.0 版本引入的 Parquet IO 功能进行了改进。详见 此处

恢复 Matplotlib 日期时间转换器注册#

pandas 实现了一些 matplotlib 转换器,用于更好地格式化绘图上带有 datetimePeriod 值的轴标签。在 pandas 0.21.0 之前,这些转换器会作为 import pandas 的副作用而隐式注册到 matplotlib 中。

在 pandas 0.21.0 中,我们要求用户显式注册转换器。这对一些依赖于这些转换器进行常规 matplotlib.pyplot 绘图方法的用户造成了问题,因此我们暂时恢复了这一更改;pandas 0.21.1 在导入时再次注册转换器,就像 0.21.0 之前一样。

我们添加了一个新选项来控制转换器:pd.options.plotting.matplotlib.register_converters。默认情况下,它们是注册的。将其切换为 False 将移除 pandas 的格式化器,并恢复我们在注册时可能覆盖的任何转换器 (GH 18301)。

我们正与 matplotlib 开发者合作,以使其更容易。我们正努力平衡用户便利性(自动注册转换器)与导入性能和最佳实践(导入 pandas 不应产生覆盖已设置的自定义转换器的副作用)。未来,我们希望大部分日期时间格式化功能都在 matplotlib 中实现,而 pandas 中只保留特定于 pandas 的转换器。届时,我们将逐步弃用自动注册转换器,转而支持用户在需要时显式注册。

新特性#

Parquet IO 功能改进#

其他改进#

弃用#

性能改进#

  • 改进了绘制大型 Series/DataFrame 的性能 (GH 18236)。

错误修复#

转换#

  • TimedeltaIndex 减法中的一个错误可能在存在 NaT 时错误地溢出 (GH 17791)。

  • DatetimeIndex 减去类日期时间(datetimelike)对象时可能无法溢出 (GH 18020)。

  • 复制具有非默认 closed 属性的 IntervalIndex 时,IntervalIndex.copy() 中存在错误 (GH 18339)。

  • DataFrame.to_dict() 中的一个错误导致在使用 orient='records' 时,时区感知的日期时间列未转换为所需的数组,从而引发 TypeError (GH 18372)。

  • DateTimeIndexdate_range() 中的一个错误导致如果 end.tzinfo 为 None,不匹配的时区感知的 startend 时区不会引发错误 (GH 18431)。

  • Series.fillna() 中的一个错误导致在 Python 2 中传递一个长整型时引发异常 (GH 18159)。

索引#

  • datetime.datetimedatetime64[ns] dtype 的 Series 进行布尔比较时存在错误 (GH 17965)。

  • 当尝试访问 MultiIndex(包含超过一百万条记录)中不存在的属性时,没有引发 AttributeError 的错误 (GH 18165)。

  • 当传入带有非默认 closed 参数的间隔列表时,IntervalIndex 构造函数中存在错误 (GH 18334)。

  • 传递无效掩码时,Index.putmask 中存在错误 (GH 18368)。

  • timedelta64[ns] dtype 的 Series 进行掩码赋值时存在错误,错误地被强制转换为浮点类型 (GH 18493)。

IO#

  • 解决了 StataReader 中未转换具有显示格式的日期/时间列的错误 (GH 17990)。之前,具有显示格式的列通常保留为序数,未转换为日期时间对象。

  • read_csv() 读取压缩的 UTF-16 编码文件时存在错误 (GH 18071)。

  • read_csv() 在指定 na_filter=False 时处理索引列中的空值存在错误 (GH 5239)。

  • read_csv() 读取高基数的数值分类字段时存在错误 (GH 18186)。

  • 当表包含 MultiIndex 列,并且为 header 参数传入了字符串列表时,DataFrame.to_csv() 中存在错误 (GH 5539)。

  • read_sql 中解析具有指定格式的整数类日期时间(datetime-like)列时存在错误 (GH 17855)。

  • 序列化 numpy.bool_ 数据类型的数据时,DataFrame.to_msgpack() 中存在错误 (GH 18390)。

  • read_json() 从 S3 读取行分隔 JSON 时未解码的错误 (GH 17200)。

  • pandas.io.json.json_normalize() 中避免修改 meta 参数的错误 (GH 18610)。

  • to_latex() 中的一个错误导致即使高层级索引与前一行不同,重复的 MultiIndex 值也没有被打印 (GH 14484)。

  • HDFStore 中读取仅包含 NaN 的分类列时存在错误 (GH 18413)。

  • 使用 longtable=True 参数时,DataFrame.to_latex() 中的一个错误导致 latex 多列始终跨越三列 (GH 17959)。

绘图#

  • 使用 DatetimeIndex 时,DataFrame.plot()Series.plot() 中的一个错误导致它们生成的图形在 Python 3 中不可 pickle (GH 18439)。

GroupBy/resample/rolling#

  • 当存在一个返回不同列的可调用对象时,DataFrame.resample(...).apply(...) 中存在错误 (GH 15169)。

  • 当发生时间变化 (DST) 且重采样频率为 12 小时或更高时,DataFrame.resample(...) 中存在错误 (GH 15549)。

  • 在对类日期时间(datetimelike)列进行计数时,pd.DataFrameGroupBy.count() 中存在错误 (GH 13393)。

  • rolling.var 中存在错误,当数组值为零时计算不准确 (GH 18430)。

重塑#

  • pd.merge_asof() 中关于键数据类型不匹配的错误消息现在包含左键和右键的数据类型 (GH 18068)。

  • pd.concat 在连接空和非空 DataFrame 或 Series 时存在错误 (GH 18178 GH 18187)。

  • 在 Python 2 中将 unicode 作为条件传递时,DataFrame.filter(...) 中存在错误 (GH 13101)。

  • 设置 np.seterr(divide='raise') 时,合并空 DataFrame 存在错误 (GH 17776)。

数值#

  • 所有值相等时,pd.Series.rolling.skew()rolling.kurt() 中存在浮点问题 (GH 18044)。

分类#

  • 在空 DataFrame 上转换为 ‘category’ 时,DataFrame.astype() 中存在错误,导致分段错误 (GH 18004)。

  • 当项目具有不同的 CategoricalDtype 时,测试模块中的错误消息已得到改进 (GH 18069)。

  • CategoricalIndex 现在可以正确地将 pd.api.types.CategoricalDtype 作为其 dtype (GH 18116)。

  • 当所有类别都为 NaN 时,Categorical.unique() 返回只读 codes 数组的错误 (GH 18051)。

  • 当使用 CategoricalIndex 时,DataFrame.groupby(axis=1) 中存在错误 (GH 18432)。

字符串#

贡献者#

共有 46 位贡献者为本次发布贡献了补丁。名字旁带有 “+” 的是首次贡献补丁的人员。

  • Aaron Critchley +

  • Alex Rychyk

  • Alexander Buchkovsky +

  • Alexander Michael Schade +

  • Chris Mazzullo

  • Cornelius Riemenschneider +

  • Dave Hirschfeld +

  • David Fischer +

  • David Stansby +

  • Dror Atariah +

  • Eric Kisslinger +

  • Hans +

  • Ingolf Becker +

  • Jan Werkmann +

  • Jeff Reback

  • Joris Van den Bossche

  • Jörg Döpfert +

  • Kevin Kuhl +

  • Krzysztof Chomski +

  • Leif Walsh

  • Licht Takeuchi

  • Manraj Singh +

  • Matt Braymer-Hayes +

  • Michael Waskom +

  • Mie~~~ +

  • Peter Hoffmann +

  • Robert Meyer +

  • Sam Cohan +

  • Sietse Brouwer +

  • Sven +

  • Tim Swast

  • Tom Augspurger

  • Wes Turner

  • William Ayd +

  • Yee Mey +

  • bolkedebruin +

  • cgohlke

  • derestle-htwg +

  • fjdiod +

  • gabrielclow +

  • gfyoung

  • ghasemnaddaf +

  • jbrockmendel

  • jschendel

  • miker985 +

  • topper-123