版本 0.14.1(2014 年 7 月 11 日)#

这是 0.14.0 的一个次要版本,包含少量 API 更改、一些新功能、增强功能和性能改进,以及大量的错误修复。我们建议所有用户升级到此版本。

API 更改#

  • Openpyxl 现在在构建 openpyxl writer 时会引发 ValueError,而不是在导入 pandas 时发出警告(GH 7284)。

  • 对于 StringMethods.extract,当没有找到匹配项时,结果(仅包含 NaN 值)现在也具有 dtype=object 而不是 floatGH 7242

  • Period 对象在使用 == 与非 Period 对象比较时不再引发 TypeError。相反,在使用 == 比较 Period 与另一个对象时,如果另一个对象不是 Period,则返回 False。(GH 7376

  • 之前,`offsets.apply`、`rollforward` 和 `rollback` 操作中是否重置时间的行为在不同偏移量之间有所不同。随着所有偏移量支持默认值为 False(保留时间)的 normalize 关键字(见下文),某些偏移量(BusinessMonthBegin、MonthEnd、BusinessMonthEnd、CustomBusinessMonthEnd、BusinessYearBegin、LastWeekOfMonth、FY5253Quarter、LastWeekOfMonth、Easter)的行为发生了变化。

    In [6]: from pandas.tseries import offsets
    
    In [7]: d = pd.Timestamp('2014-01-01 09:00')
    
    # old behaviour < 0.14.1
    In [8]: d + offsets.MonthEnd()
    Out[8]: pd.Timestamp('2014-01-31 00:00:00')
    

    从 0.14.1 开始,所有偏移量默认保留时间。可以通过设置 normalize=True 获得旧的行为。

    # new behaviour
    In [1]: d + offsets.MonthEnd()
    Out[1]: Timestamp('2014-01-31 09:00:00')
    
    In [2]: d + offsets.MonthEnd(normalize=True)
    Out[2]: Timestamp('2014-01-31 00:00:00')
    

    请注意,对于其他偏移量,默认行为没有改变。

  • 在文本解析中重新添加 #N/A N/A 作为默认的 NA 值(0.12 版本的回退)(GH 5521

  • 当使用 .where 和非 np.nan 值进行原地设置时,会引发 TypeError,因为这与 df[mask] = None 这样的设置项表达式不一致(GH 7656

增强功能#

  • value_countsnunique 添加 dropna 参数(GH 5569)。

  • 添加 select_dtypes() 方法以根据 dtype 选择列(GH 7316)。请参阅 文档

  • 所有 offsets 都支持 normalize 关键字,用于指定 offsets.applyrollforwardrollback 是否重置时间(小时、分钟等)(默认为 False,保留时间)(GH 7156

    import pandas.tseries.offsets as offsets
    
    day = offsets.Day()
    day.apply(pd.Timestamp("2014-01-01 09:00"))
    
    day = offsets.Day(normalize=True)
    day.apply(pd.Timestamp("2014-01-01 09:00"))
    
  • PeriodIndex 的表示格式与 DatetimeIndex 相同(GH 7601

  • StringMethods 现在可以在空 Series 上工作(GH 7242

  • 文件解析器 read_csvread_table 现在会忽略由参数 comment 提供的行注释,该参数对于 C reader 只接受单个字符。特别地,它们允许在文件数据开始之前出现注释(GH 2685

  • 对于 read_csv() 同时使用 chunksizenrows 的情况,添加 NotImplementedErrorGH 6774)。

  • 现在存在针对公共 S3 桶基本读取的测试(GH 7281)。

  • read_html 现在支持一个 encoding 参数,该参数会传递给底层的解析库。您可以使用此参数读取非 ascii 编码的网页(GH 7323)。

  • read_excel 现在支持以与 read_csv 相同的方式从 URL 读取(GH 6809)。

  • 支持 dateutil 时区,现在可以在 pandas 中以与 pytz 时区相同的方式使用它们(GH 4688)。

    In [3]: rng = pd.date_range(
       ...:     "3/6/2012 00:00", periods=10, freq="D", tz="dateutil/Europe/London"
       ...: )
       ...: 
    
    In [4]: rng.tz
    Out[4]: tzfile('/usr/share/zoneinfo/Europe/London')
    

    请参阅 文档

  • SeriesDataFramePanelGroupby 实现了 sem(平均值标准误差)操作(GH 6897

  • nlargestnsmallest 添加到 Series groupby 允许列表,这意味着您现在可以在 SeriesGroupBy 对象上使用这些方法(GH 7053)。

  • 所有 offsets 的 applyrollforwardrollback 方法现在可以处理 np.datetime64,之前会导致 ApplyTypeErrorGH 7452

  • PeriodPeriodIndex 的值中可以包含 NaTGH 7485

  • 支持对沿项目轴(分别为 indexcolumnsitems)带有非唯一标签的 SeriesDataFramePanel 对象进行序列化 (pickling)(GH 7370)。

  • 改进了混合 null 对象的 datetime/timedelta 推断。修复了 0.13.1 版本中对所有元素为 null 的对象 Index 的解释回归(GH 7431

性能改进#

  • 数值运算中的 dtype 推断得到改进,为 dtype:int64timedelta64datetime64 带来了性能提升(GH 7223

  • Series.transform 性能得到改进,带来显著的性能提升(GH 6496

  • 使用 ufuncs 和内置 grouper 函数时,DataFrame.transform 性能得到改进,带来显著的性能提升(GH 7383

  • datetime64 dtype 的 groupby 聚合出现回归(GH 7555

  • MultiIndex.from_product 对于大型可迭代对象性能得到改进(GH 7627

实验性更改#

  • pandas.io.data.Options 新增了 get_all_data 方法,现在稳定地返回一个 MultiIndexed DataFrameGH 5602

  • io.gbq.read_gbqio.gbq.to_gbq 经过重构,移除了对 Google bq.py 命令行客户端的依赖。此子模块现在使用 httplib2 以及 Google apiclientoauth2client API 客户端库,这些库应该比 bq.py 更稳定可靠。请参阅 文档。(GH 6937)。

错误修复#

  • DataFrame.where 中存在一个 bug,当帧具有对称形状并传递另一个 DataFrame 时(GH 7506

  • 使用带有 MultiIndex 轴的 Panel 索引时存在 bug(GH 7516

  • 带有重复索引和非精确端点的日期时间类切片索引中存在回归(GH 7523

  • 使用列表的列表以及单一类型与混合类型进行 setitem 时存在 bug(GH 7551):)

  • 非对齐 Series 进行时间操作时存在 bug(GH 7500

  • 分配不完整 Series 时,timedelta 推断中存在 bug(GH 7592

  • groupby .nth 与 Series 和整数类列名一起使用时存在 bug(GH 7559

  • Series.get 与布尔访问器一起使用时存在 bug(GH 7407

  • value_counts 中存在 bug,其中 NaT 不被视为缺失值(NaN)(GH 7423

  • to_timedelta 中存在 bug,它接受了无效单位并错误解释了 ‘m/h’(GH 7611GH 6423

  • 如果 secondary_y=True,则折线图未设置正确的 xlim,存在 bug(GH 7459

  • 分组的 histscatter 图使用旧的 figsize 默认值,存在 bug(GH 7394

  • 使用 DataFrame.plot 绘制子图时存在 bug,即使子图数量为一个,hist 也会清除传递的 axGH 7391)。

  • 使用 DataFrame.boxplot 并带 by 关键字绘制子图时存在 bug,如果子图数量超过 1,则会引发 ValueErrorGH 7391)。

  • 子图显示 ticklabelslabels 的规则不同,存在 bug(GH 5897

  • Panel.apply 与 MultiIndex 作为轴一起使用时存在 bug(GH 7469

  • DatetimeIndex.insert 未保留 nametz 属性,存在 bug(GH 7299

  • DatetimeIndex.asobject 未保留 name 属性,存在 bug(GH 7299

  • 使用日期时间类范围(字符串和 Timestamps)进行 MultiIndex 切片时存在 bug(GH 7429

  • Index.minmax 未正确处理 nanNaT,存在 bug(GH 7261

  • PeriodIndex.min/max 结果为 int,存在 bug(GH 7609

  • resample 中存在 bug,如果你传递了 how,则 fill_method 会被忽略(GH 2073

  • TimeGrouper 未排除由 key 指定的列,存在 bug(GH 7227

  • DataFrameSeries 的 bar 和 barh 图在指定 bottomleft 关键字时引发 TypeError,存在 bug(GH 7226

  • DataFrame.hist 在包含非数值列时引发 TypeError,存在 bug(GH 7277

  • Index.delete 未保留 namefreq 属性,存在 bug(GH 7302

  • DataFrame.query()/eval 中存在 bug,其中带有 @ 符号的本地字符串变量被视为尝试删除的临时变量(GH 7300)。

  • Float64Index 中存在 bug,它不允许重复项(GH 7149)。

  • DataFrame.replace() 中存在 bug,其中 truthy 值被替换了(GH 7140)。

  • StringMethods.extract() 中存在 bug,其中单个匹配组 Series 会使用 matcher 的名称而不是组名(GH 7313)。

  • isnull() 中存在 bug,当 mode.use_inf_as_null == True 时,当遇到 inf/-inf 时,isnull 不会测试为 TrueGH 7315)。

  • 对于东半球时区,inferred_freq 结果为 None,存在 bug(GH 7310

  • 当偏移量为负时,Easter 返回不正确的日期,存在 bug(GH 7195

  • 使用 .div、整数 dtype 和除以零进行广播时存在 bug(GH 7325

  • CustomBusinessDay.apply 在传递 np.datetime64 对象时引发 NameError,存在 bug(GH 7196

  • MultiIndex.appendconcatpivot_table 未保留时区,存在 bug(GH 6606

  • 使用 .loc 在单个 MultiIndex 级别(非嵌套)上使用索引器列表时存在 bug(GH 7349

  • Series.map 在映射具有不同长度元组键的字典时存在 bug(GH 7333

  • 所有 StringMethods 现在都可以在空 Series 上工作,修复了 bug(GH 7242

  • 修复了当查询不包含 ‘select’ 时,read_sql 委托给 read_sql_query 的问题(GH 7324)。

  • 向带有 Float64IndexDataFrame 分配字符串列名时,在调用 np.isnan 期间会引发 TypeError,存在 bug(GH 7366)。

  • NDFrame.replace() 未正确替换包含 Period 值的对象,存在 bug(GH 7379)。

  • .ix 的 getitem 应始终返回 Series,存在 bug(GH 7150

  • 使用不完整索引器进行 MultiIndex 切片时存在 bug(GH 7399

  • 在切片级别中使用步长进行 MultiIndex 切片时存在 bug(GH 7400

  • 修正了 DatetimeIndex 中负数索引器切片不正确的问题 (GH 7408)

  • 修正了 NaTMultiIndex 中未正确表示的问题 (GH 7406, GH 7409)。

  • 修正了 convert_objects 中布尔对象被转换为 nan 的问题 (GH 7416)。

  • 修正了 quantile 忽略 axis 关键字参数的问题 (GH 7306)

  • 修正了 nanops._maybe_null_out 不支持复数的问题 (GH 7353)

  • 修正了当 axis==0 时,一维 nan 数组在多个 nanops 函数中的问题 (GH 7354)

  • 修正了当 axis==Nonenanops.nanmedian 不工作的问题 (GH 7352)

  • 修正了 nanops._has_infs 不支持多种 dtypes 的问题 (GH 7357)

  • 修正了 StataReader.data 读取 0 个观测值的 dta 文件失败的问题 (GH 7369)

  • 修正了 StataReader 读取包含固定宽度字符串的 Stata 13 (117) 文件时的问题 (GH 7360)

  • 修正了 StataWriter 忽略编码的问题 (GH 7286)

  • 修正了 DatetimeIndex 比较未能正确处理 NaT 的问题 (GH 7529)

  • 修正了将带有 tzinfo 的输入传递给某些 offset 的 apply, rollforwardrollback 方法时,会重置 tzinfo 或引发 ValueError 的问题 (GH 7465)

  • 修正了 DatetimeIndex.to_period, PeriodIndex.asobject, PeriodIndex.to_timestamp 未保留 name 的问题 (GH 7485)

  • 修正了 DatetimeIndex.to_periodPeriodIndex.to_timestamp 处理 NaT 不正确的问题 (GH 7228)

  • 修正了 offsets.apply, rollforwardrollback 可能返回普通 datetime 的问题 (GH 7502)

  • 修正了当目标包含 NaT 时,resample 引发 ValueError 的问题 (GH 7227)

  • 修正了 Timestamp.tz_localize 重置 nanosecond 信息的问题 (GH 7534)

  • 修正了当 DatetimeIndex.asobject 包含 NaT 时引发 ValueError 的问题 (GH 7539)

  • 修正了 Timestamp.__new__ 未正确保留纳秒信息的问题 (GH 7610)

  • 修正了 Index.astype(float) 返回 object dtype 的 Index 的问题 (GH 7464)。

  • 修正了 DataFrame.reset_index 丢失 tz (时区)的问题 (GH 3950)

  • 修正了当 freqNone 时,DatetimeIndex.freqstr 引发 AttributeError 的问题 (GH 7606)

  • 修正了由 TimeGrouper 创建的 GroupBy.size 引发 AttributeError 的问题 (GH 7453)

  • 修正了单列条形图对齐不正确的问题 (GH 7498)。

  • 修正了带有 tz-aware 时间序列的面积图引发 ValueError 的问题 (GH 7471)

  • 修正了非单调的 Index.union 可能错误地保留 name 的问题 (GH 7458)

  • 修正了 DatetimeIndex.intersection 未保留时区的问题 (GH 4690)

  • 修正了 rolling_var 中窗口大小大于数组时会引发错误的问题 (GH 7297)

  • 修正了最后一个绘制的时间序列决定 xlim 的问题 (GH 2960)

  • 修正了 secondary_y 轴未被考虑用于时间序列 xlim 的问题 (GH 3490)

  • 修正了 Float64Index 使用非标量索引器进行赋值的问题 (GH 7586)

  • 修正了当 regex=Falsecase=False 时,pandas.core.strings.str_contains 未能正确地进行大小写不敏感匹配的问题 (GH 7505)

  • 修正了当两个参数索引不匹配时,expanding_cov, expanding_corr, rolling_covrolling_corr 中的问题 (GH 7512)

  • 修正了 to_sql 将布尔列视为文本列的问题 (GH 7678)

  • 修正了分组 hist 未能正确处理 rot kw 和 sharex kw 参数的问题 (GH 7234)

  • 修正了 .locobject dtype 索引执行回退整数索引的问题 (GH 7496)

  • 修正了 PeriodIndex 构造函数在传递 Series 对象时的问题(回归错误)(GH 7701)。

贡献者#

共有 46 人为此版本贡献了补丁。名字旁带有“+”的人是首次贡献补丁。

  • Andrew Rosenfeld

  • Andy Hayden

  • Benjamin Adams +

  • Benjamin M. Gross +

  • Brian Quistorff +

  • Brian Wignall +

  • DSM

  • Daniel Waeber

  • David Bew +

  • David Stephens

  • Jacob Schaer

  • Jan Schulz

  • John David Reaver

  • John W. O’Brien

  • Joris Van den Bossche

  • Julien Danjou +

  • K.-Michael Aye

  • Kevin Sheppard

  • Kyle Meyer

  • Matt Wittmann

  • Matthew Brett +

  • Michael Mueller +

  • Mortada Mehyar

  • Phillip Cloud

  • Rob Levy +

  • Schaer, Jacob C +

  • Stephan Hoyer

  • Thomas Kluyver

  • Todd Jennings

  • Tom Augspurger

  • TomAugspurger

  • bwignall

  • clham

  • dsm054 +

  • helger +

  • immerrr

  • jaimefrio

  • jreback

  • lexual

  • onesandzeroes

  • rockg

  • sanguineturtle +

  • seth-p +

  • sinhrks

  • unknown

  • yelite +