title: Conditionally sort a single column in ascending and descending order in Pandas
body: <p>I have 98,000 USA home street addresses that I need to sort in 'walking' order, i.e. listed in the order that you would walk, down one side of the street and then cross the street and walk back.</p>
  
  <pre><code>import pandas as pd
  df = pd.read_excel('c:pdsort.xlsx')
  
  # add boolean column for even or odd on number column
  is_even = df.loc[:,'number'] % 2 == 0
  df.loc[:, 'even'] = is_even
  
  # group and then sort by number
  df.groupby(['town','street','even']).apply(lambda x: x.sort_values('number'))
  
  # sort odd numbers ascending and even numbers descending
  </code></pre>
  
  <p>Desired df results, sort ascending for odd street numbers, then switch to descending sort for even. [sorry, first stackoverflow question, don't qualify yet to copy image of Jupyter notebook]</p>
  
  <p></p>
  
  <p>4 columns: number,street,town,even</p>
  
  <p>desired outcome for column 'number':
  1231
  1233
  1235
  1237
  1239
  1238
  1236
  1234
  1232
  1230</p>