41
pandas: powerful Python data analysis toolkit, Release 0.18.1
• an i/o interface to Google’s BigQuery
Their are several new or updated docs sections including:
• ComparisonwithSQL, which should be useful for those familiarwith SQL but still learning pandas.
• ComparisonwithR,idiom translations fromR to pandas.
• EnhancingPerformance, ways to enhance pandas performance with eval/query.
Warning: In 0.13.0 Series has internally been refactored to nolongersub-class ndarray but insteadsubclass
NDFrame, similar tothe rest of the pandas containers. This should be a transparent change with onlyvery limited
API implications. SeeInternalRefactoring
1.14.1 API changes
• read_excel now supports an integer in its sheetname argument giving the index of the sheet to read in
(GH4301).
• Text parser now treats anything that reads like inf (“inf”, “Inf”, “-Inf”, “iNf”, etc.) as infinity. (GH4220,
GH4219),affectingread_table,read_csv,etc.
• pandas now is Python 2/3 compatible without the need for 2to3 thanks to @jtratner. As a result, pandas now
uses iterators more extensively. This also led to the introduction ofsubstantive parts of the BenjaminPeterson’s
six library into compat. (GH4384,GH4375,GH4372)
• pandas.util.compat and pandas.util.py3compat have been merged into pandas.compat.
pandas.compat now includes many functions allowing 2/3 compatibility. It contains both list and itera-
tor versions of range, filter, map and zip, plus other necessary elements for Python 3 compatibility. lmap,
lzip,lrange andlfilter allproduce lists instead ofiterators,forcompatibilitywith numpy,subscripting
and pandas constructors.(GH4384,GH4375,GH4372)
• Series.get with negative indexers nowreturns the same as [] (GH4390)
• Changes to how Index andMultiIndex handle metadata (levels,labels, and names) (GH4039):
# previously, you would have set levels or labels directly
index.levels = [[1, 2, , 3, , 4], [1, 2, , 4, , 4]]
# now, you use the set_levels or set_labels methods
index = index.set_levels([[1, , 2, 3, 4], [1, , 2, , 4, 4]])
# similarly, for names, you can rename the object
# but setting names is not deprecated
index = index.set_names(["bob", "cranberry"])
# and all methods take an inplace kwarg - but return None
index.set_names(["bob", "cranberry"], inplace=True)
• All division withNDFrame objects is nowtruedivision,regardless ofthe future import. This means thatoperat-
ing on pandas objects will by default use floating point division, and return a floating point dtype. You can use
// and floordiv to do integerdivision.
Integer division
In [3]: arr = np.array([1, 2, 3, 4])
In [4]: arr2 = np.array([5, 3, 2, 1])
188
Chapter 1. What’s New