版本 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.applyrollforwardrollback 操作中重置時間或不重置時間的行為在不同偏移量之間存在差異。隨著對所有偏移量支援 normalize 關鍵字(如下文所述),其預設值為 False(保留時間),某些偏移量的行為發生了變化(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 讀取器中的單個字元。特別是,它們允許在檔案資料開始之前出現註釋(GH 2685)。

  • 為 read_csv() 同時使用 chunksizenrows 新增 NotImplementedErrorGH 6774)。

  • 現在存在對公共 S3 儲存桶基本讀取的測試(GH 7281)。

  • read_html 現在擁有一個 encoding 引數,該引數會傳遞給底層解析器庫。您可以使用它來讀取非 ASCII 編碼的網頁(GH 7323)。

  • read_excel 現在支援從 URL 讀取,方式與 read_csv 相同。(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)。

  • 所有偏移量 applyrollforwardrollback 現在都可以處理 np.datetime64,以前會導致 ApplyTypeErrorGH 7452)。

  • PeriodPeriodIndex 的值可以包含 NaTGH 7485)。

  • 支援對具有非唯一標籤(沿*item*軸,分別為 indexcolumnsitems)的 SeriesDataFramePanel 物件進行 pickle(GH 7370)。

  • 改進了混合 null 物件的 datetime/timedelta 推斷。迴歸(0.13.1 版)在解釋具有所有 null 元素的 object Index 時。(GH 7431)。

效能#

  • 改進了涉及產生以下 dtypes 效能提升的數值運算的 dtype 推斷:int64timedelta64datetime64GH 7223)。

  • 改進了 Series.transform,實現了顯著的效能提升(GH 6496)。

  • 改進了 DataFrame.transform 對 ufuncs 和內建分組函式的支援,實現了顯著的效能提升(GH 7383)。

  • datetime64 dtypes 的 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)。

Bug 修復#

  • DataFrame.where 與對稱形狀的 frame 和傳遞的 DataFrame other 之間的錯誤(GH 7506)。

  • Panel 索引與 MultiIndex 軸之間的錯誤(GH 7516)。

  • 帶有重複索引和非精確端點的 datetimelike 切片索引迴歸(GH 7523)。

  • setItem 與 list-of-lists 和單值 vs 混合型別之間的錯誤(GH 7551:)。

  • 時間操作與非對齊 Series 之間的錯誤(GH 7500)。

  • 分配不完整 Series 時 timedelta 推斷中的錯誤(GH 7592)。

  • groupby .nth 與 Series 和整數類列名之間的錯誤(GH 7559)。

  • Series.get 與布林訪問器之間的錯誤(GH 7407)。

  • value_countsNaT 未被視為缺失(NaN)的錯誤(GH 7423)。

  • to_timedelta 接受無效單位並錯誤解釋“m/h”的錯誤(GH 7611, GH 6423)。

  • 折線圖不設定正確 xlim(當 secondary_y=True 時)的錯誤(GH 7459)。

  • 分組的 histscatter 圖使用舊 figsize 預設值的錯誤(GH 7394)。

  • DataFrame.plot 的子圖繪圖錯誤,即使子圖數量為一時,hist 也會清除傳入的 axGH 7391)。

  • DataFrame.boxplot 帶有 by 關鍵字引數的子圖繪圖錯誤,如果子圖數量超過 1,則引發 ValueErrorGH 7391)。

  • 子圖顯示 ticklabelslabels 規則不同的錯誤(GH 5897)。

  • Panel.apply 與 MultiIndex 作為軸之間的錯誤(GH 7469)。

  • DatetimeIndex.insert 未能保留 nametz 的錯誤(GH 7299)。

  • DatetimeIndex.asobject 未能保留 name 的錯誤(GH 7299)。

  • MultiIndex 切片與 datetimelike 範圍(字串和 Timestamps)之間的錯誤(GH 7429)。

  • Index.min 和 max 未能正確處理 nanNaT 的錯誤(GH 7261)。

  • PeriodIndex.min/max 結果為 int 的錯誤(GH 7609)。

  • resample 中 fill_method 被忽略(當傳遞 how 時)的錯誤(GH 2073)。

  • TimeGrouper 未能排除由 key 指定的列的錯誤(GH 7227)。

  • DataFrame 和 Series 的 bar 和 barh 圖在指定 bottomleft 關鍵字時引發 TypeError 的錯誤(GH 7226)。

  • DataFrame.hist 在包含非數字列時引發 TypeError 的錯誤(GH 7277)。

  • Index.delete 未能保留 namefreq 屬性的錯誤(GH 7302)。

  • DataFrame.query()/eval 中,帶有 @ 符號的本地字串變數被視為臨時變數嘗試刪除的錯誤(GH 7300)。

  • Float64Index 不允許重複的錯誤(GH 7149)。

  • DataFrame.replace() 替換了真值(truthy values)的錯誤(GH 7140)。

  • StringMethods.extract() 中,單匹配組 Series 使用匹配器的名稱而不是組名稱的錯誤(GH 7313)。

  • isnull() 在 mode.use_inf_as_null == True 時,當遇到 inf/-inf 時,isnull() 不會測試 True 的錯誤(GH 7315)。

  • inferred_freq 在東半球時區結果為 None 的錯誤(GH 7310)。

  • Easter 返回錯誤日期的錯誤(當偏移量為負時)(GH 7195)。

  • 使用 .div、整數 dtypes 和除零操作進行廣播的錯誤(GH 7325)。

  • CustomBusinessDay.apply 在傳遞 np.datetime64 物件時引發 NameError 的錯誤(GH 7196)。

  • MultiIndex.append、concat 和 pivot_table 未能保留時區的錯誤(GH 6606)。

  • 對非巢狀的單層 MultiIndex 使用帶有索引器列表的 .loc 的錯誤(GH 7349)。

  • Series.map 在對映具有不同長度元組鍵的字典時出現的錯誤(GH 7333)。

  • 所有 StringMethods 現在都可以在空 Series 上工作(GH 7242)。

  • 修復了當查詢不包含 'select' 時,read_sql 委託給 read_sql_query 的問題(GH 7324)。

  • 當將字串列名分配給具有 Float64IndexDataFrame 時,在呼叫 np.isnan 期間引發 TypeError 的錯誤(GH 7366)。

  • NDFrame.replace() 未能正確替換具有 Period 值的物件的錯誤(GH 7379)。

  • .ix getitem 應該始終返回 Series 的錯誤(GH 7150)。

  • MultiIndex 切片與不完整索引器的錯誤(GH 7399)。

  • MultiIndex 切片中,在一個切片級別上使用步長(step)的錯誤(GH 7400)。

  • 負索引器在 DatetimeIndex 中未能正確切片的錯誤(GH 7408)。

  • MultiIndexNaT 未能正確 repr 的錯誤(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==None 時,nanops.nanmedian 不起作用的錯誤(GH 7352)。

  • nanops._has_infs 對多種 dtype 不起作用的錯誤(GH 7357)。

  • StataReader.data 讀取 0 行 dta 檔案失敗的錯誤(GH 7369)。

  • StataReader 讀取包含固定寬度字串的 Stata 13 (117) 檔案時的錯誤(GH 7360)。

  • StataWriter 忽略編碼的錯誤(GH 7286)。

  • DatetimeIndex 比較未能正確處理 NaT 的錯誤(GH 7529)。

  • 將帶有 tzinfo 的輸入傳遞給某些偏移量的 applyrollforwardrollback 會重置 tzinfo 或引發 ValueError 的錯誤(GH 7465)。

  • DatetimeIndex.to_period, PeriodIndex.asobject, PeriodIndex.to_timestamp 未能保留 name 的錯誤(GH 7485)。

  • DatetimeIndex.to_period 和 PeriodIndex.to_timestamp 處理 NaT 不正確的錯誤(GH 7228)。

  • offsets.apply, rollforward 和 rollback 可能會返回普通的 datetime 的錯誤(GH 7502)。

  • resample 在目標包含 NaT 時引發 ValueError 的錯誤(GH 7227)。

  • Timestamp.tz_localize 重置 nanosecond 資訊(GH 7534)。

  • DatetimeIndex.asobject 在包含 NaT 時引發 ValueError 的錯誤(GH 7539)。

  • Timestamp.__new__ 未能正確保留 nanosecond 的錯誤(GH 7610)。

  • Index.astype(float) 會返回 object dtype Index 的錯誤(GH 7464)。

  • DataFrame.reset_index 丟失 tz 的錯誤(GH 3950)。

  • DatetimeIndex.freqstr 在 freqNone 時引發 AttributeError 的錯誤(GH 7606)。

  • 由 TimeGrouper 建立的 GroupBy.size 引發 AttributeError 的錯誤(GH 7453)。

  • 單列條形圖中的錯誤,圖例對齊有問題 (GH 7498)。

  • 帶有時區感知的時序資料的面積圖中的錯誤,引發 ValueError (GH 7471)

  • 非單調 Index.union 中的錯誤,可能錯誤地保留 name (GH 7458)

  • DatetimeIndex.intersection 中的錯誤,未保留時區 (GH 4690)

  • rolling_var 中的錯誤,當視窗大於陣列時會引發錯誤 (GH 7297)

  • 最後一個繪製的時序決定了 xlim 的錯誤 (GH 2960)

  • 在時序 xlim 中未考慮 secondary_y 軸的錯誤 (GH 3490)

  • Float64Index 賦值時,使用非標量索引器的錯誤 (GH 7586)

  • pandas.core.strings.str_contains 中的錯誤,當 regex=Falsecase=False 時,不區分大小寫匹配不正確 (GH 7505)

  • expanding_cov, expanding_corr, rolling_cov, 和 rolling_corr 中,兩個引數索引不匹配的錯誤 (GH 7512)

  • to_sql 中,將布林列視為文字列的錯誤 (GH 7678)

  • 在分組的 hist 中,未能正確處理 rotsharex 引數的錯誤 (GH 7234)

  • .loc 執行回退整數索引(使用 object 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 +