Version 0.15.1 (November 9, 2014)¶
This is a minor bug-fix release from 0.15.0 and includes a small number of API changes, several new features, enhancements, and performance improvements along with a large number of bug fixes. We recommend that all users upgrade to this version.
API changes¶
s.dt.hourand other.dtaccessors will now returnnp.nanfor missing values (rather than previously -1), (GH8689)In [1]: s = pd.Series(pd.date_range("20130101", periods=5, freq="D")) In [2]: s.iloc[2] = np.nan In [3]: s Out[3]: 0 2013-01-01 1 2013-01-02 2 NaT 3 2013-01-04 4 2013-01-05 Length: 5, dtype: datetime64[ns]
previous behavior:
In [6]: s.dt.hour Out[6]: 0 0 1 0 2 -1 3 0 4 0 dtype: int64
current behavior:
In [4]: s.dt.hour Out[4]: 0 0.0 1 0.0 2 NaN 3 0.0 4 0.0 Length: 5, dtype: float64
groupbywithas_index=Falsewill not add erroneous extra columns to result (GH8582):In [5]: np.random.seed(2718281) In [6]: df = pd.DataFrame(np.random.randint(0, 100, (10, 2)), columns=["jim", "joe"]) In [7]: df.head() Out[7]: jim joe 0 61 81 1 96 49 2 55 65 3 72 51 4 77 12 [5 rows x 2 columns] In [8]: ts = pd.Series(5 * np.random.randint(0, 3, 10))
previous behavior:
In [4]: df.groupby(ts, as_index=False).max() Out[4]: NaN jim joe 0 0 72 83 1 5 77 84 2 10 96 65
current behavior:
In [9]: df.groupby(ts, as_index=False).max() Out[9]: jim joe 0 72 83 1 77 84 2 96 65 [3 rows x 2 columns]
groupbywill not erroneously exclude columns if the column name conflicts with the grouper name (GH8112):In [10]: df = pd.DataFrame({"jim": range(5), "joe": range(5, 10)}) In [11]: df Out[11]: jim joe 0 0 5 1 1 6 2 2 7 3 3 8 4 4 9 [5 rows x 2 columns] In [12]: gr = df.groupby(df["jim"] < 2)
previous behavior (excludes 1st column from output):
In [4]: gr.apply(sum) Out[4]: joe jim False 24 True 11
current behavior:
In [13]: gr.apply(sum) Out[13]: jim joe jim False 9 24 True 1 11 [2 rows x 2 columns]
Support for slicing with monotonic decreasing indexes, even if
startorstopis not found in the index (GH7860):In [14]: s = pd.Series(["a", "b", "c", "d"], [4, 3, 2, 1]) In [15]: s Out[15]: 4 a 3 b 2 c 1 d Length: 4, dtype: object
previous behavior:
In [8]: s.loc[3.5:1.5] KeyError: 3.5
current behavior:
In [16]: s.loc[3.5:1.5] Out[16]: 3 b 2 c Length: 2, dtype: object
io.data.Optionshas been fixed for a change in the format of the Yahoo Options page (GH8612), (GH8741)Note
As a result of a change in Yahoo’s option page layout, when an expiry date is given,
Optionsmethods now return data for a single expiry date. Previously, methods returned all data for the selected month.The
monthandyearparameters have been undeprecated and can be used to get all options data for a given month.If an expiry date that is not valid is given, data for the next expiry after the given date is returned.
Option data frames are now saved on the instance as
callsYYMMDDorputsYYMMDD. Previously they were saved ascallsMMYYandputsMMYY. The next expiry is saved ascallsandputs.New features:
The expiry parameter can now be a single date or a list-like object containing dates.
A new property
expiry_dateswas added, which returns all available expiry dates.
Current behavior:
In [17]: from pandas.io.data import Options In [18]: aapl = Options('aapl', 'yahoo') In [19]: aapl.get_call_data().iloc[0:5, 0:1] Out[19]: Last Strike Expiry Type Symbol 80 2014-11-14 call AAPL141114C00080000 29.05 84 2014-11-14 call AAPL141114C00084000 24.80 85 2014-11-14 call AAPL141114C00085000 24.05 86 2014-11-14 call AAPL141114C00086000 22.76 87 2014-11-14 call AAPL141114C00087000 21.74 In [20]: aapl.expiry_dates Out[20]: [datetime.date(2014, 11, 14), datetime.date(2014, 11, 22), datetime.date(2014, 11, 28), datetime.date(2014, 12, 5), datetime.date(2014, 12, 12), datetime.date(2014, 12, 20), datetime.date(2015, 1, 17), datetime.date(2015, 2, 20), datetime.date(2015, 4, 17), datetime.date(2015, 7, 17), datetime.date(2016, 1, 15), datetime.date(2017, 1, 20)] In [21]: aapl.get_near_stock_price(expiry=aapl.expiry_dates[0:3]).iloc[0:5, 0:1] Out[21]: Last Strike Expiry Type Symbol 109 2014-11-22 call AAPL141122C00109000 1.48 2014-11-28 call AAPL141128C00109000 1.79 110 2014-11-14 call AAPL141114C00110000 0.55 2014-11-22 call AAPL141122C00110000 1.02 2014-11-28 call AAPL141128C00110000 1.32
pandas now also registers the
datetime64dtype in matplotlib’s units registry to plot such values as datetimes. This is activated once pandas is imported. In previous versions, plotting an array ofdatetime64values will have resulted in plotted integer values. To keep the previous behaviour, you can dodel matplotlib.units.registry[np.datetime64](GH8614).
Enhancements¶
concatpermits a wider variety of iterables of pandas objects to be passed as the first parameter (GH8645):In [17]: from collections import deque In [18]: df1 = pd.DataFrame([1, 2, 3]) In [19]: df2 = pd.DataFrame([4, 5, 6])
previous behavior:
In [7]: pd.concat(deque((df1, df2))) TypeError: first argument must be a list-like of pandas objects, you passed an object of type "deque"
current behavior:
In [20]: pd.concat(deque((df1, df2))) Out[20]: 0 0 1 1 2 2 3 0 4 1 5 2 6 [6 rows x 1 columns]
Represent
MultiIndexlabels with a dtype that utilizes memory based on the level size. In prior versions, the memory usage was a constant 8 bytes per element in each level. In addition, in prior versions, the reported memory usage was incorrect as it didn’t show the usage for the memory occupied by the underling data array. (GH8456)In [21]: dfi = pd.DataFrame( ....: 1, index=pd.MultiIndex.from_product([["a"], range(1000)]), columns=["A"] ....: ) ....:
previous behavior:
# this was underreported in prior versions In [1]: dfi.memory_usage(index=True) Out[1]: Index 8000 # took about 24008 bytes in < 0.15.1 A 8000 dtype: int64
current behavior:
In [22]: dfi.memory_usage(index=True) Out[22]: Index 44212 A 8000 Length: 2, dtype: int64
Added Index properties
is_monotonic_increasingandis_monotonic_decreasing(GH8680).Added option to select columns when importing Stata files (GH7935)
Qualify memory usage in
DataFrame.info()by adding+if it is a lower bound (GH8578)Raise errors in certain aggregation cases where an argument such as
numeric_onlyis not handled (GH8592).Added support for 3-character ISO and non-standard country codes in
io.wb.download()(GH8482)World Bank data requests now will warn/raise based on an
errorsargument, as well as a list of hard-coded country codes and the World Bank’s JSON response. In prior versions, the error messages didn’t look at the World Bank’s JSON response. Problem-inducing input were simply dropped prior to the request. The issue was that many good countries were cropped in the hard-coded approach. All countries will work now, but some bad countries will raise exceptions because some edge cases break the entire response. (GH8482)Added option to
Series.str.split()to return aDataFramerather than aSeries(GH8428)Added option to
df.info(null_counts=None|True|False)to override the default display options and force showing of the null-counts (GH8701)
Bug fixes¶
Bug in unpickling of a
CustomBusinessDayobject (GH8591)Bug in coercing
Categoricalto a records array, e.g.df.to_records()(GH8626)Bug in
Categoricalnot created properly withSeries.to_frame()(GH8626)Bug in coercing in astype of a
Categoricalof a passedpd.Categorical(this now raisesTypeErrorcorrectly), (GH8626)Bug in
cut/qcutwhen usingSeriesandretbins=True(GH8589)Bug in writing Categorical columns to an SQL database with
to_sql(GH8624).Bug in comparing
Categoricalof datetime raising when being compared to a scalar datetime (GH8687)Bug in selecting from a
Categoricalwith.iloc(GH8623)Bug in groupby-transform with a Categorical (GH8623)
Bug in duplicated/drop_duplicates with a Categorical (GH8623)
Bug in
Categoricalreflected comparison operator raising if the first argument was a numpy array scalar (e.g. np.int64) (GH8658)Bug in Panel indexing with a list-like (GH8710)
Compat issue is
DataFrame.dtypeswhenoptions.mode.use_inf_as_nullis True (GH8722)Bug in
read_csv,dialectparameter would not take a string (GH8703)Bug in slicing a MultiIndex level with an empty-list (GH8737)
Bug in numeric index operations of add/sub with Float/Index Index with numpy arrays (GH8608)
Bug in setitem with empty indexer and unwanted coercion of dtypes (GH8669)
Bug in ix/loc block splitting on setitem (manifests with integer-like dtypes, e.g. datetime64) (GH8607)
Bug when doing label based indexing with integers not found in the index for non-unique but monotonic indexes (GH8680).
Bug when indexing a Float64Index with
np.nanon numpy 1.7 (GH8980).Fix
shapeattribute forMultiIndex(GH8609)Bug in
GroupBywhere a name conflict between the grouper and columns would breakgroupbyoperations (GH7115, GH8112)Fixed a bug where plotting a column
yand specifying a label would mutate the index name of the original DataFrame (GH8494)Fix regression in plotting of a DatetimeIndex directly with matplotlib (GH8614).
Bug in
date_rangewhere partially-specified dates would incorporate current date (GH6961)Bug in Setting by indexer to a scalar value with a mixed-dtype
Panel4dwas failing (GH8702)Bug where
DataReader’s would fail if one of the symbols passed was invalid. Now returns data for valid symbols and np.nan for invalid (GH8494)Bug in
get_quote_yahoothat wouldn’t allow non-float return values (GH5229).
Contributors¶
A total of 23 people contributed patches to this release. People with a “+” by their names contributed a patch for the first time.
Aaron Staple +
Andrew Rosenfeld
Anton I. Sipos
Artemy Kolchinsky
Bill Letson +
Dave Hughes +
David Stephens
Guillaume Horel +
Jeff Reback
Joris Van den Bossche
Kevin Sheppard
Nick Stahl +
Sanghee Kim +
Stephan Hoyer
Tom Augspurger
TomAugspurger
WANG Aiyong +
behzad nouri
immerrr
jnmclarty
jreback
pallav-fdsi +
unutbu