Skip to content

Commit 78d6955

Browse files
meghanacosmosKevin D Smith
authored and
Kevin D Smith
committed
DOC: doc/source/whatsnew (pandas-dev#36857)
1 parent aa6765c commit 78d6955

23 files changed

+472
-436
lines changed

doc/source/whatsnew/v0.10.0.rst

+16-13
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ talking about:
4949
:okwarning:
5050
5151
import pandas as pd
52-
df = pd.DataFrame(np.random.randn(6, 4),
53-
index=pd.date_range('1/1/2000', periods=6))
52+
53+
df = pd.DataFrame(np.random.randn(6, 4), index=pd.date_range("1/1/2000", periods=6))
5454
df
5555
# deprecated now
5656
df - df[0]
@@ -184,12 +184,14 @@ labeled the aggregated group with the end of the interval: the next day).
184184
185185
import io
186186
187-
data = ('a,b,c\n'
188-
'1,Yes,2\n'
189-
'3,No,4')
187+
data = """
188+
a,b,c
189+
1,Yes,2
190+
3,No,4
191+
"""
190192
print(data)
191193
pd.read_csv(io.StringIO(data), header=None)
192-
pd.read_csv(io.StringIO(data), header=None, prefix='X')
194+
pd.read_csv(io.StringIO(data), header=None, prefix="X")
193195
194196
- Values like ``'Yes'`` and ``'No'`` are not interpreted as boolean by default,
195197
though this can be controlled by new ``true_values`` and ``false_values``
@@ -199,7 +201,7 @@ labeled the aggregated group with the end of the interval: the next day).
199201
200202
print(data)
201203
pd.read_csv(io.StringIO(data))
202-
pd.read_csv(io.StringIO(data), true_values=['Yes'], false_values=['No'])
204+
pd.read_csv(io.StringIO(data), true_values=["Yes"], false_values=["No"])
203205
204206
- The file parsers will not recognize non-string values arising from a
205207
converter function as NA if passed in the ``na_values`` argument. It's better
@@ -210,10 +212,10 @@ labeled the aggregated group with the end of the interval: the next day).
210212

211213
.. ipython:: python
212214
213-
s = pd.Series([np.nan, 1., 2., np.nan, 4])
215+
s = pd.Series([np.nan, 1.0, 2.0, np.nan, 4])
214216
s
215217
s.fillna(0)
216-
s.fillna(method='pad')
218+
s.fillna(method="pad")
217219
218220
Convenience methods ``ffill`` and ``bfill`` have been added:
219221

@@ -229,7 +231,8 @@ Convenience methods ``ffill`` and ``bfill`` have been added:
229231
.. ipython:: python
230232
231233
def f(x):
232-
return pd.Series([x, x**2], index=['x', 'x^2'])
234+
return pd.Series([x, x ** 2], index=["x", "x^2"])
235+
233236
234237
s = pd.Series(np.random.rand(5))
235238
s
@@ -272,20 +275,20 @@ The old behavior of printing out summary information can be achieved via the
272275

273276
.. ipython:: python
274277
275-
pd.set_option('expand_frame_repr', False)
278+
pd.set_option("expand_frame_repr", False)
276279
277280
wide_frame
278281
279282
.. ipython:: python
280283
:suppress:
281284
282-
pd.reset_option('expand_frame_repr')
285+
pd.reset_option("expand_frame_repr")
283286
284287
The width of each line can be changed via 'line_width' (80 by default):
285288

286289
.. code-block:: python
287290
288-
pd.set_option('line_width', 40)
291+
pd.set_option("line_width", 40)
289292
290293
wide_frame
291294

doc/source/whatsnew/v0.10.1.rst

+34-30
Original file line numberDiff line numberDiff line change
@@ -45,49 +45,51 @@ You may need to upgrade your existing data files. Please visit the
4545
4646
import os
4747
48-
os.remove('store.h5')
48+
os.remove("store.h5")
4949
5050
You can designate (and index) certain columns that you want to be able to
5151
perform queries on a table, by passing a list to ``data_columns``
5252

5353
.. ipython:: python
5454
55-
store = pd.HDFStore('store.h5')
56-
df = pd.DataFrame(np.random.randn(8, 3),
57-
index=pd.date_range('1/1/2000', periods=8),
58-
columns=['A', 'B', 'C'])
59-
df['string'] = 'foo'
60-
df.loc[df.index[4:6], 'string'] = np.nan
61-
df.loc[df.index[7:9], 'string'] = 'bar'
62-
df['string2'] = 'cool'
55+
store = pd.HDFStore("store.h5")
56+
df = pd.DataFrame(
57+
np.random.randn(8, 3),
58+
index=pd.date_range("1/1/2000", periods=8),
59+
columns=["A", "B", "C"],
60+
)
61+
df["string"] = "foo"
62+
df.loc[df.index[4:6], "string"] = np.nan
63+
df.loc[df.index[7:9], "string"] = "bar"
64+
df["string2"] = "cool"
6365
df
6466
6567
# on-disk operations
66-
store.append('df', df, data_columns=['B', 'C', 'string', 'string2'])
67-
store.select('df', "B>0 and string=='foo'")
68+
store.append("df", df, data_columns=["B", "C", "string", "string2"])
69+
store.select("df", "B>0 and string=='foo'")
6870
6971
# this is in-memory version of this type of selection
70-
df[(df.B > 0) & (df.string == 'foo')]
72+
df[(df.B > 0) & (df.string == "foo")]
7173
7274
Retrieving unique values in an indexable or data column.
7375

7476
.. code-block:: python
7577
7678
# note that this is deprecated as of 0.14.0
7779
# can be replicated by: store.select_column('df','index').unique()
78-
store.unique('df', 'index')
79-
store.unique('df', 'string')
80+
store.unique("df", "index")
81+
store.unique("df", "string")
8082
8183
You can now store ``datetime64`` in data columns
8284

8385
.. ipython:: python
8486
8587
df_mixed = df.copy()
86-
df_mixed['datetime64'] = pd.Timestamp('20010102')
87-
df_mixed.loc[df_mixed.index[3:4], ['A', 'B']] = np.nan
88+
df_mixed["datetime64"] = pd.Timestamp("20010102")
89+
df_mixed.loc[df_mixed.index[3:4], ["A", "B"]] = np.nan
8890
89-
store.append('df_mixed', df_mixed)
90-
df_mixed1 = store.select('df_mixed')
91+
store.append("df_mixed", df_mixed)
92+
df_mixed1 = store.select("df_mixed")
9193
df_mixed1
9294
df_mixed1.dtypes.value_counts()
9395
@@ -97,7 +99,7 @@ columns, this is equivalent to passing a
9799

98100
.. ipython:: python
99101
100-
store.select('df', columns=['A', 'B'])
102+
store.select("df", columns=["A", "B"])
101103
102104
``HDFStore`` now serializes MultiIndex dataframes when appending tables.
103105

@@ -160,29 +162,31 @@ combined result, by using ``where`` on a selector table.
160162

161163
.. ipython:: python
162164
163-
df_mt = pd.DataFrame(np.random.randn(8, 6),
164-
index=pd.date_range('1/1/2000', periods=8),
165-
columns=['A', 'B', 'C', 'D', 'E', 'F'])
166-
df_mt['foo'] = 'bar'
165+
df_mt = pd.DataFrame(
166+
np.random.randn(8, 6),
167+
index=pd.date_range("1/1/2000", periods=8),
168+
columns=["A", "B", "C", "D", "E", "F"],
169+
)
170+
df_mt["foo"] = "bar"
167171
168172
# you can also create the tables individually
169-
store.append_to_multiple({'df1_mt': ['A', 'B'], 'df2_mt': None},
170-
df_mt, selector='df1_mt')
173+
store.append_to_multiple(
174+
{"df1_mt": ["A", "B"], "df2_mt": None}, df_mt, selector="df1_mt"
175+
)
171176
store
172177
173178
# individual tables were created
174-
store.select('df1_mt')
175-
store.select('df2_mt')
179+
store.select("df1_mt")
180+
store.select("df2_mt")
176181
177182
# as a multiple
178-
store.select_as_multiple(['df1_mt', 'df2_mt'], where=['A>0', 'B>0'],
179-
selector='df1_mt')
183+
store.select_as_multiple(["df1_mt", "df2_mt"], where=["A>0", "B>0"], selector="df1_mt")
180184
181185
.. ipython:: python
182186
:suppress:
183187
184188
store.close()
185-
os.remove('store.h5')
189+
os.remove("store.h5")
186190
187191
**Enhancements**
188192

doc/source/whatsnew/v0.12.0.rst

+28-22
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ API changes
4747

4848
.. ipython:: python
4949
50-
p = pd.DataFrame({'first': [4, 5, 8], 'second': [0, 0, 3]})
50+
p = pd.DataFrame({"first": [4, 5, 8], "second": [0, 0, 3]})
5151
p % 0
5252
p % p
5353
p / p
@@ -95,8 +95,8 @@ API changes
9595

9696
.. ipython:: python
9797
98-
df = pd.DataFrame(range(5), index=list('ABCDE'), columns=['a'])
99-
mask = (df.a % 2 == 0)
98+
df = pd.DataFrame(range(5), index=list("ABCDE"), columns=["a"])
99+
mask = df.a % 2 == 0
100100
mask
101101
102102
# this is what you should use
@@ -141,21 +141,24 @@ API changes
141141
.. code-block:: python
142142
143143
from pandas.io.parsers import ExcelFile
144-
xls = ExcelFile('path_to_file.xls')
145-
xls.parse('Sheet1', index_col=None, na_values=['NA'])
144+
145+
xls = ExcelFile("path_to_file.xls")
146+
xls.parse("Sheet1", index_col=None, na_values=["NA"])
146147
147148
With
148149

149150
.. code-block:: python
150151
151152
import pandas as pd
152-
pd.read_excel('path_to_file.xls', 'Sheet1', index_col=None, na_values=['NA'])
153+
154+
pd.read_excel("path_to_file.xls", "Sheet1", index_col=None, na_values=["NA"])
153155
154156
- added top-level function ``read_sql`` that is equivalent to the following
155157

156158
.. code-block:: python
157159
158160
from pandas.io.sql import read_frame
161+
159162
read_frame(...)
160163
161164
- ``DataFrame.to_html`` and ``DataFrame.to_latex`` now accept a path for
@@ -200,7 +203,7 @@ IO enhancements
200203
.. ipython:: python
201204
:okwarning:
202205
203-
df = pd.DataFrame({'a': range(3), 'b': list('abc')})
206+
df = pd.DataFrame({"a": range(3), "b": list("abc")})
204207
print(df)
205208
html = df.to_html()
206209
alist = pd.read_html(html, index_col=0)
@@ -248,16 +251,18 @@ IO enhancements
248251
.. ipython:: python
249252
250253
from pandas._testing import makeCustomDataframe as mkdf
254+
251255
df = mkdf(5, 3, r_idx_nlevels=2, c_idx_nlevels=4)
252-
df.to_csv('mi.csv')
253-
print(open('mi.csv').read())
254-
pd.read_csv('mi.csv', header=[0, 1, 2, 3], index_col=[0, 1])
256+
df.to_csv("mi.csv")
257+
print(open("mi.csv").read())
258+
pd.read_csv("mi.csv", header=[0, 1, 2, 3], index_col=[0, 1])
255259
256260
.. ipython:: python
257261
:suppress:
258262
259263
import os
260-
os.remove('mi.csv')
264+
265+
os.remove("mi.csv")
261266
262267
- Support for ``HDFStore`` (via ``PyTables 3.0.0``) on Python3
263268

@@ -304,8 +309,8 @@ Other enhancements
304309

305310
.. ipython:: python
306311
307-
df = pd.DataFrame({'a': list('ab..'), 'b': [1, 2, 3, 4]})
308-
df.replace(regex=r'\s*\.\s*', value=np.nan)
312+
df = pd.DataFrame({"a": list("ab.."), "b": [1, 2, 3, 4]})
313+
df.replace(regex=r"\s*\.\s*", value=np.nan)
309314
310315
to replace all occurrences of the string ``'.'`` with zero or more
311316
instances of surrounding white space with ``NaN``.
@@ -314,7 +319,7 @@ Other enhancements
314319

315320
.. ipython:: python
316321
317-
df.replace('.', np.nan)
322+
df.replace(".", np.nan)
318323
319324
to replace all occurrences of the string ``'.'`` with ``NaN``.
320325

@@ -359,16 +364,16 @@ Other enhancements
359364

360365
.. ipython:: python
361366
362-
dff = pd.DataFrame({'A': np.arange(8), 'B': list('aabbbbcc')})
363-
dff.groupby('B').filter(lambda x: len(x) > 2)
367+
dff = pd.DataFrame({"A": np.arange(8), "B": list("aabbbbcc")})
368+
dff.groupby("B").filter(lambda x: len(x) > 2)
364369
365370
Alternatively, instead of dropping the offending groups, we can return a
366371
like-indexed objects where the groups that do not pass the filter are
367372
filled with NaNs.
368373

369374
.. ipython:: python
370375
371-
dff.groupby('B').filter(lambda x: len(x) > 2, dropna=False)
376+
dff.groupby("B").filter(lambda x: len(x) > 2, dropna=False)
372377
373378
- Series and DataFrame hist methods now take a ``figsize`` argument (:issue:`3834`)
374379

@@ -397,17 +402,18 @@ Experimental features
397402
398403
from pandas.tseries.offsets import CustomBusinessDay
399404
from datetime import datetime
405+
400406
# As an interesting example, let's look at Egypt where
401407
# a Friday-Saturday weekend is observed.
402-
weekmask_egypt = 'Sun Mon Tue Wed Thu'
408+
weekmask_egypt = "Sun Mon Tue Wed Thu"
403409
# They also observe International Workers' Day so let's
404410
# add that for a couple of years
405-
holidays = ['2012-05-01', datetime(2013, 5, 1), np.datetime64('2014-05-01')]
411+
holidays = ["2012-05-01", datetime(2013, 5, 1), np.datetime64("2014-05-01")]
406412
bday_egypt = CustomBusinessDay(holidays=holidays, weekmask=weekmask_egypt)
407413
dt = datetime(2013, 4, 30)
408414
print(dt + 2 * bday_egypt)
409415
dts = pd.date_range(dt, periods=5, freq=bday_egypt)
410-
print(pd.Series(dts.weekday, dts).map(pd.Series('Mon Tue Wed Thu Fri Sat Sun'.split())))
416+
print(pd.Series(dts.weekday, dts).map(pd.Series("Mon Tue Wed Thu Fri Sat Sun".split())))
411417
412418
Bug fixes
413419
~~~~~~~~~
@@ -430,14 +436,14 @@ Bug fixes
430436
.. ipython:: python
431437
:okwarning:
432438
433-
strs = 'go', 'bow', 'joe', 'slow'
439+
strs = "go", "bow", "joe", "slow"
434440
ds = pd.Series(strs)
435441
436442
for s in ds.str:
437443
print(s)
438444
439445
s
440-
s.dropna().values.item() == 'w'
446+
s.dropna().values.item() == "w"
441447
442448
The last element yielded by the iterator will be a ``Series`` containing
443449
the last element of the longest string in the ``Series`` with all other

0 commit comments

Comments
 (0)