@@ -1219,8 +1219,8 @@ see :ref:`here <basics.pipe>`.
1219
1219
Combining ``.groupby `` and ``.pipe `` is often useful when you need to reuse
1220
1220
GroupBy objects.
1221
1221
1222
- For an example, imagine having a DataFrame with columns for stores, products,
1223
- revenue and sold quantity. We'd like to do a groupwise calculation of *prices *
1222
+ As an example, imagine having a DataFrame with columns for stores, products,
1223
+ revenue and quantity sold . We'd like to do a groupwise calculation of *prices *
1224
1224
(i.e. revenue/quantity) per store and per product. We could do this in a
1225
1225
multi-step operation, but expressing it in terms of piping can make the
1226
1226
code more readable. First we set the data:
@@ -1230,7 +1230,7 @@ code more readable. First we set the data:
1230
1230
import numpy as np
1231
1231
n = 1000
1232
1232
df = pd.DataFrame({' Store' : np.random.choice([' Store_1' , ' Store_2' ], n),
1233
- ' Product' : np.random.choice([' Product_1' , ' Product_2' , ' Product_3 ' ], n),
1233
+ ' Product' : np.random.choice([' Product_1' ,' Product_2' ], n),
1234
1234
' Revenue' : (np.random.random(n)* 50 + 10 ).round(2 ),
1235
1235
' Quantity' : np.random.randint(1 , 10 , size = n)})
1236
1236
df.head(2 )
0 commit comments