Skip to content

Commit 21d0c9c

Browse files
committed
Added example for Excel Filters and Fill handle
1 parent ce1f81f commit 21d0c9c

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

doc/source/cookbook.rst

+34
Original file line numberDiff line numberDiff line change
@@ -1354,3 +1354,37 @@ of the data values:
13541354
'weight': [100, 140, 180],
13551355
'sex': ['Male', 'Female']})
13561356
df
1357+
1358+
Common Excel Operations
1359+
-----------------------
1360+
1361+
Fill Handle
1362+
***********
1363+
1364+
Create a series of numbers in a DataFrame.
1365+
1366+
.. ipython:: python
1367+
1368+
df = pd.DataFrame({'AAA': [1]*8, 'BBB': list(range(0,8))}); df
1369+
1370+
# Fill numbers with difference 4 starting from 1
1371+
# in rows 2 to 5 in column AAA.
1372+
1373+
df.iloc[2:(5+1)].AAA = [ x*4 + 2 for x in range(0, len(df.iloc[2:(5+1)])) ]
1374+
1375+
df
1376+
1377+
Filters
1378+
*******
1379+
1380+
.. ipython:: python
1381+
1382+
# Filter by value 0 in column AAA
1383+
1384+
df[df.AAA == 0]
1385+
1386+
# Filter by multiple values
1387+
1388+
df[(df.AAA == 0) | (df.AAA == 2)]
1389+
1390+

0 commit comments

Comments
 (0)