Skip to content

Commit 9f3a0d2

Browse files
Alvaro Tejero-Canterowesm
Alvaro Tejero-Cantero
authored andcommitted
DOC: Apply PEP8 to code chunks in HDFStore doc (except Term lists, for readability).
1 parent 9be0c8a commit 9f3a0d2

File tree

1 file changed

+33
-26
lines changed

1 file changed

+33
-26
lines changed

doc/source/io.rst

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -975,8 +975,8 @@ one can use the ExcelWriter class, as in the following example:
975975
HDF5 (PyTables)
976976
---------------
977977

978-
``HDFStore`` is a dict-like object which reads and writes pandas to the
979-
high performance HDF5 format using the excellent `PyTables
978+
``HDFStore`` is a dict-like object which reads and writes pandas using
979+
the high performance HDF5 format using the excellent `PyTables
980980
<http://www.pytables.org/>`__ library.
981981

982982
.. ipython:: python
@@ -1041,7 +1041,8 @@ Closing a Store
10411041
# closing a store
10421042
store.close()
10431043
1044-
# Working with, and automatically closing the store with the context manager
1044+
# Working with, and automatically closing the store with the context
1045+
# manager
10451046
with get_store('store.h5') as store:
10461047
store.keys()
10471048
@@ -1137,7 +1138,7 @@ defaults to `nan`.
11371138
df_mixed['datetime64'] = Timestamp('20010102')
11381139
df_mixed.ix[3:5,['A','B','string','datetime64']] = np.nan
11391140
1140-
store.append('df_mixed', df_mixed, min_itemsize = { 'values' : 50 })
1141+
store.append('df_mixed', df_mixed, min_itemsize = {'values': 50})
11411142
df_mixed1 = store.select('df_mixed')
11421143
df_mixed1
11431144
df_mixed1.get_dtype_counts()
@@ -1159,7 +1160,7 @@ storing/selecting from homogenous index DataFrames.
11591160
[0, 1, 2, 0, 1, 1, 2, 0, 1, 2]],
11601161
names=['foo', 'bar'])
11611162
df_mi = DataFrame(np.random.randn(10, 3), index=index,
1162-
columns=['A', 'B', 'C'])
1163+
columns=['A', 'B', 'C'])
11631164
df_mi
11641165
11651166
store.append('df_mi',df_mi)
@@ -1192,10 +1193,10 @@ terms.
11921193
- ``dict(field = 'index', op = '>', value = '20121114')``
11931194
- ``('index', '>', '20121114')``
11941195
- ``'index > 20121114'``
1195-
- ``('index', '>', datetime(2012,11,14))``
1196-
- ``('index', ['20121114','20121115'])``
1196+
- ``('index', '>', datetime(2012, 11, 14))``
1197+
- ``('index', ['20121114', '20121115'])``
11971198
- ``('major_axis', '=', Timestamp('2012/11/14'))``
1198-
- ``('minor_axis', ['A','B'])``
1199+
- ``('minor_axis', ['A', 'B'])``
11991200

12001201
Queries are built up using a list of ``Terms`` (currently only
12011202
**anding** of terms is supported). An example query for a panel might be
@@ -1207,15 +1208,15 @@ greater than the date 20000102 and the minor_axis must be A or B`
12071208
12081209
store.append('wp',wp)
12091210
store
1210-
store.select('wp',[ Term('major_axis>20000102'), Term('minor_axis', '=', ['A','B']) ])
1211+
store.select('wp', [ Term('major_axis>20000102'), Term('minor_axis', '=', ['A', 'B']) ])
12111212
12121213
The ``columns`` keyword can be supplied to select to filter a list of
12131214
the return columns, this is equivalent to passing a
12141215
``Term('columns',list_of_columns_to_filter)``
12151216

12161217
.. ipython:: python
12171218
1218-
store.select('df', columns = ['A','B'])
1219+
store.select('df', columns=['A', 'B'])
12191220
12201221
Start and Stop parameters can be specified to limit the total search
12211222
space. These are in terms of the total number of rows in a table.
@@ -1226,7 +1227,9 @@ space. These are in terms of the total number of rows in a table.
12261227
wp.to_frame()
12271228
12281229
# limiting the search
1229-
store.select('wp',[ Term('major_axis>20000102'), Term('minor_axis', '=', ['A','B']) ], start=0, stop=10)
1230+
store.select('wp',[ Term('major_axis>20000102'),
1231+
Term('minor_axis', '=', ['A','B']) ],
1232+
start=0, stop=10)
12301233
12311234
12321235
Indexing
@@ -1273,11 +1276,11 @@ be data_columns
12731276
df_dc
12741277
12751278
# on-disk operations
1276-
store.append('df_dc', df_dc, data_columns = ['B','C','string','string2'])
1277-
store.select('df_dc',[ Term('B>0') ])
1279+
store.append('df_dc', df_dc, data_columns = ['B', 'C', 'string', 'string2'])
1280+
store.select('df_dc', [ Term('B>0') ])
12781281
12791282
# getting creative
1280-
store.select('df_dc',[ 'B > 0', 'C > 0', 'string == foo' ])
1283+
store.select('df_dc', ['B > 0', 'C > 0', 'string == foo'])
12811284
12821285
# this is in-memory version of this type of selection
12831286
df_dc[(df_dc.B > 0) & (df_dc.C > 0) & (df_dc.string == 'foo')]
@@ -1303,8 +1306,8 @@ very quickly. Note ``nan`` are excluded from the result set.
13031306

13041307
.. ipython:: python
13051308
1306-
store.unique('df_dc','index')
1307-
store.unique('df_dc','string')
1309+
store.unique('df_dc', 'index')
1310+
store.unique('df_dc', 'string')
13081311
13091312
**Replicating or**
13101313

@@ -1317,7 +1320,7 @@ criteria to the table, and then ``concat`` the results.
13171320
crit1 = [ Term('B>0'), Term('C>0'), Term('string=foo') ]
13181321
crit2 = [ Term('B<0'), Term('C>0'), Term('string=foo') ]
13191322
1320-
concat([ store.select('df_dc',c) for c in [ crit1, crit2 ] ])
1323+
concat([store.select('df_dc',c) for c in [crit1, crit2]])
13211324
13221325
**Storer Object**
13231326

@@ -1357,16 +1360,17 @@ table (optional) to let it have the remaining columns. The argument
13571360
df_mt['foo'] = 'bar'
13581361
13591362
# you can also create the tables individually
1360-
store.append_to_multiple({ 'df1_mt' : ['A','B'], 'df2_mt' : None },
1361-
df_mt, selector = 'df1_mt')
1363+
store.append_to_multiple({'df1_mt': ['A', 'B'], 'df2_mt': None },
1364+
df_mt, selector='df1_mt')
13621365
store
13631366
13641367
# indiviual tables were created
13651368
store.select('df1_mt')
13661369
store.select('df2_mt')
13671370
13681371
# as a multiple
1369-
store.select_as_multiple(['df1_mt','df2_mt'], where = [ 'A>0','B>0' ], selector = 'df1_mt')
1372+
store.select_as_multiple(['df1_mt','df2_mt'], where=['A>0', 'B>0'],
1373+
selector = 'df1_mt')
13701374
13711375
13721376
Delete from a Table
@@ -1431,7 +1435,8 @@ may not be installed (by Python) by default.
14311435

14321436
Compression for all objects within the file
14331437

1434-
- ``store_compressed = HDFStore('store_compressed.h5', complevel=9, complib='blosc')``
1438+
- ``store_compressed = HDFStore('store_compressed.h5', complevel=9,
1439+
complib='blosc')``
14351440

14361441
Or on-the-fly compression (this only applies to tables). You can turn
14371442
off file compression for a specific table by passing ``complevel=0``
@@ -1446,7 +1451,8 @@ beginning. You can use the supplied ``PyTables`` utility
14461451
``ptrepack``. In addition, ``ptrepack`` can change compression levels
14471452
after the fact.
14481453

1449-
- ``ptrepack --chunkshape=auto --propindexes --complevel=9 --complib=blosc in.h5 out.h5``
1454+
- ``ptrepack --chunkshape=auto --propindexes --complevel=9
1455+
--complib=blosc in.h5 out.h5``
14501456

14511457
Furthermore ``ptrepack in.h5 out.h5`` will *repack* the file to allow
14521458
you to reuse previously deleted space. Aalternatively, one can simply
@@ -1515,12 +1521,13 @@ conversion may not be necessary in future versions of pandas)
15151521
.. ipython:: python
15161522
15171523
import datetime
1518-
df = DataFrame(dict(datelike = Series([datetime.datetime(2001,1,1),datetime.datetime(2001,1,2),np.nan])))
1524+
df = DataFrame(dict(datelike=Series([datetime.datetime(2001, 1, 1),
1525+
datetime.datetime(2001, 1, 2), np.nan])))
15191526
df
15201527
df.dtypes
15211528
15221529
# to convert
1523-
df['datelike'] = Series(df['datelike'].values,dtype='M8[ns]')
1530+
df['datelike'] = Series(df['datelike'].values, dtype='M8[ns]')
15241531
df
15251532
df.dtypes
15261533
@@ -1537,7 +1544,7 @@ format store like this:
15371544
.. ipython:: python
15381545
15391546
store_export = HDFStore('export.h5')
1540-
store_export.append('df_dc',df_dc,data_columns=df_dc.columns)
1547+
store_export.append('df_dc', df_dc, data_columns=df_dc.columns)
15411548
store_export
15421549

15431550
.. ipython:: python
@@ -1629,7 +1636,7 @@ object). This cannot be changed after table creation.
16291636

16301637
.. ipython:: python
16311638
1632-
store.append('p4d2', p4d, axes = ['labels','major_axis','minor_axis'])
1639+
store.append('p4d2', p4d, axes=['labels', 'major_axis', 'minor_axis'])
16331640
store
16341641
store.select('p4d2', [ Term('labels=l1'), Term('items=Item1'), Term('minor_axis=A_big_strings') ])
16351642

0 commit comments

Comments
 (0)