5252These are some neat pandas ``idioms ``
5353
5454`if-then/if-then-else on one column, and assignment to another one or more columns:
55- <http ://stackoverflow.com/questions/17128302/python-pandas-idiom-for-if-then-else> `__
55+ <https ://stackoverflow.com/questions/17128302/python-pandas-idiom-for-if-then-else> `__
5656
5757.. ipython :: python
5858
@@ -88,7 +88,7 @@ Or use pandas where after you've set up a mask
8888 df.where(df_mask,- 1000 )
8989
9090 `if-then-else using numpy's where()
91- <http ://stackoverflow.com/questions/19913659/pandas-conditional-creation-of-a-series-dataframe-column> `__
91+ <https ://stackoverflow.com/questions/19913659/pandas-conditional-creation-of-a-series-dataframe-column> `__
9292
9393.. ipython :: python
9494
@@ -101,7 +101,7 @@ Splitting
101101*********
102102
103103`Split a frame with a boolean criterion
104- <http ://stackoverflow.com/questions/14957116/how-to-split-a-dataframe-according-to-a-boolean-criterion> `__
104+ <https ://stackoverflow.com/questions/14957116/how-to-split-a-dataframe-according-to-a-boolean-criterion> `__
105105
106106.. ipython :: python
107107
@@ -115,7 +115,7 @@ Building Criteria
115115*****************
116116
117117`Select with multi-column criteria
118- <http ://stackoverflow.com/questions/15315452/selecting-with-complex-criteria-from-pandas-dataframe> `__
118+ <https ://stackoverflow.com/questions/15315452/selecting-with-complex-criteria-from-pandas-dataframe> `__
119119
120120.. ipython :: python
121121
@@ -141,7 +141,7 @@ Building Criteria
141141 df.loc[(df[' BBB' ] > 25 ) | (df[' CCC' ] >= 75 ), ' AAA' ] = 0.1 ; df
142142
143143 `Select rows with data closest to certain value using argsort
144- <http ://stackoverflow.com/questions/17758023/return-rows-in-a-dataframe-closest-to-a-user-defined-number> `__
144+ <https ://stackoverflow.com/questions/17758023/return-rows-in-a-dataframe-closest-to-a-user-defined-number> `__
145145
146146.. ipython :: python
147147
@@ -152,7 +152,7 @@ Building Criteria
152152 df.loc[(df.CCC - aValue).abs().argsort()]
153153
154154 `Dynamically reduce a list of criteria using a binary operators
155- <http ://stackoverflow.com/questions/21058254/pandas-boolean-operation-in-a-python-list/21058331> `__
155+ <https ://stackoverflow.com/questions/21058254/pandas-boolean-operation-in-a-python-list/21058331> `__
156156
157157.. ipython :: python
158158
@@ -189,7 +189,7 @@ DataFrames
189189The :ref: `indexing <indexing >` docs.
190190
191191`Using both row labels and value conditionals
192- <http ://stackoverflow.com/questions/14725068/pandas-using-row-labels-in-boolean-indexing> `__
192+ <https ://stackoverflow.com/questions/14725068/pandas-using-row-labels-in-boolean-indexing> `__
193193
194194.. ipython :: python
195195
@@ -232,7 +232,7 @@ Ambiguity arises when an index consists of integers with a non-zero start or non
232232 df2.loc[1 :3 ] # Label-oriented
233233
234234 `Using inverse operator (~) to take the complement of a mask
235- <http ://stackoverflow.com/questions/14986510/picking-out-elements-based-on-complement-of-indices-in-python-pandas> `__
235+ <https ://stackoverflow.com/questions/14986510/picking-out-elements-based-on-complement-of-indices-in-python-pandas> `__
236236
237237.. ipython :: python
238238
@@ -259,13 +259,13 @@ Panels
259259 pf.loc[:,:,' F' ] = pd.DataFrame(data, rng, cols);pf
260260
261261 `Mask a panel by using np.where and then reconstructing the panel with the new masked values
262- <http ://stackoverflow.com/questions/14650341/boolean-mask-in-pandas-panel> `__
262+ <https ://stackoverflow.com/questions/14650341/boolean-mask-in-pandas-panel> `__
263263
264264New Columns
265265***********
266266
267267`Efficiently and dynamically creating new columns using applymap
268- <http ://stackoverflow.com/questions/16575868/efficiently-creating-additional-columns-in-a-pandas-dataframe-using-map> `__
268+ <https ://stackoverflow.com/questions/16575868/efficiently-creating-additional-columns-in-a-pandas-dataframe-using-map> `__
269269
270270.. ipython :: python
271271
@@ -279,7 +279,7 @@ New Columns
279279 df[new_cols] = df[source_cols].applymap(categories.get);df
280280
281281 `Keep other columns when using min() with groupby
282- <http ://stackoverflow.com/questions/23394476/keep-other-columns-when-using-min-with-groupby> `__
282+ <https ://stackoverflow.com/questions/23394476/keep-other-columns-when-using-min-with-groupby> `__
283283
284284.. ipython :: python
285285
@@ -308,7 +308,7 @@ MultiIndexing
308308The :ref: `multindexing <advanced.hierarchical >` docs.
309309
310310`Creating a MultiIndex from a labeled frame
311- <http ://stackoverflow.com/questions/14916358/reshaping-dataframes-in-pandas-based-on-column-labels> `__
311+ <https ://stackoverflow.com/questions/14916358/reshaping-dataframes-in-pandas-based-on-column-labels> `__
312312
313313.. ipython :: python
314314
@@ -331,7 +331,7 @@ Arithmetic
331331**********
332332
333333`Performing arithmetic with a MultiIndex that needs broadcasting
334- <http ://stackoverflow.com/questions/19501510/divide-entire-pandas-multiindex-dataframe-by-dataframe-variable/19502176#19502176> `__
334+ <https ://stackoverflow.com/questions/19501510/divide-entire-pandas-multiindex-dataframe-by-dataframe-variable/19502176#19502176> `__
335335
336336.. ipython :: python
337337
@@ -343,7 +343,7 @@ Slicing
343343*******
344344
345345`Slicing a MultiIndex with xs
346- <http ://stackoverflow.com/questions/12590131/how-to-slice-multindex-columns-in-pandas-dataframes> `__
346+ <https ://stackoverflow.com/questions/12590131/how-to-slice-multindex-columns-in-pandas-dataframes> `__
347347
348348.. ipython :: python
349349
@@ -364,7 +364,7 @@ To take the cross section of the 1st level and 1st axis the index:
364364 df.xs(' six' ,level = 1 ,axis = 0 )
365365
366366 `Slicing a MultiIndex with xs, method #2
367- <http ://stackoverflow.com/questions/14964493/multiindex-based-indexing-in-pandas> `__
367+ <https ://stackoverflow.com/questions/14964493/multiindex-based-indexing-in-pandas> `__
368368
369369.. ipython :: python
370370
@@ -387,13 +387,13 @@ To take the cross section of the 1st level and 1st axis the index:
387387 df.loc[(All,' Math' ),(All,' II' )]
388388
389389 `Setting portions of a MultiIndex with xs
390- <http ://stackoverflow.com/questions/19319432/pandas-selecting-a-lower-level-in-a-dataframe-to-do-a-ffill> `__
390+ <https ://stackoverflow.com/questions/19319432/pandas-selecting-a-lower-level-in-a-dataframe-to-do-a-ffill> `__
391391
392392Sorting
393393*******
394394
395395`Sort by specific column or an ordered list of columns, with a MultiIndex
396- <http ://stackoverflow.com/questions/14733871/mutli-index-sorting-in-pandas> `__
396+ <https ://stackoverflow.com/questions/14733871/mutli-index-sorting-in-pandas> `__
397397
398398.. ipython :: python
399399
0 commit comments