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

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

主要亮点包括

  • 暂时恢复 matplotlib datetime 绘图功能。这应该能解决那些隐式依赖 pandas 使用 matplotlib 绘制 datetime 的用户所遇到的问题。详见此处

  • 对 0.21.0 中引入的 Parquet I/O 函数进行了改进。详见此处

恢复 Matplotlib datetime 转换器注册#

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 不应有覆盖您已设置的任何自定义转换器的副作用)。将来,我们希望将大部分 datetime 格式化功能放在 matplotlib 中,而只在 pandas 中保留 pandas 特定的转换器。届时,我们将逐步弃用自动注册转换器,转而推荐用户在需要时显式注册它们。

新功能#

对 Parquet I/O 功能的改进#

其他改进#

弃用#

性能改进#

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

错误修复#

转换#

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

  • DatetimeIndex 从 DatetimeIndex 减去 datetime 类似值时可能无法溢出 (GH 18020) 的错误

  • 复制带有非默认 closedIntervalIndexIntervalIndex.copy() 中的错误 (GH 18339)

  • 使用 orient='records' 时,DataFrame.to_dict() 中 tz-aware 的 datetime 列未转换为所需数组,导致 TypeError 的错误 (GH 18372)

  • DateTimeIndexdate_range() 中的错误,其中不匹配的 tz-aware startend 时区在 end.tzinfo 为 None 时不会引发错误 (GH 18431)

  • 在 Python 2 中,当传入长整型时,Series.fillna() 报错的错误 (GH 18159)。

索引#

  • datetime.datetimedatetime64[ns] dtype Series 的布尔比较中的错误 (GH 17965)

  • 当尝试访问缺失属性时,具有超过一百万条记录的 MultiIndex 未引发 AttributeError 的错误 (GH 18165)

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

  • 传入无效 mask 时 Index.putmask 中的错误 (GH 18368)

  • 遮罩赋值 timedelta64[ns] dtype Series 时,错误地强制转换为 float 的错误 (GH 18493)

I/O#

  • StataReader 未转换带有显示格式的日期/时间列的错误已解决 (GH 17990)。此前,带有显示格式的列通常被保留为序数,而未转换为 datetime 对象。

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

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

  • 读取高基数数值类别字段时 read_csv() 中的错误 (GH 18186)

  • 当表具有 MultiIndex 列并且为 header 传入字符串列表时,DataFrame.to_csv() 中的错误 (GH 5539)

  • read_sql 中解析具有指定格式的整数 datetime 类似列的错误 (GH 17855)。

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

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

  • 为避免修改 meta 而在 pandas.io.json.json_normalize() 中发现的错误 (GH 18610)

  • to_latex() 中,即使更高层级的索引与前一行不同,重复的 MultiIndex 值也未打印的错误 (GH 14484)

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

  • 在使用 longtable=True 时,DataFrame.to_latex() 中的错误,其中 latex multicolumn 总是跨越三列 (GH 17959)

绘图#

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

GroupBy/重采样/滚动#

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

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

  • 当对 datetime 类似列进行计数时,pd.DataFrameGroupBy.count() 中的错误 (GH 13393)

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

重塑#

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

  • 当空 DataFrame 和非空 DataFrame 或 Series 连接时,pd.concat 中的错误 (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)

  • 带有 CategoricalIndexDataFrame.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