title: Pandas Dataframe - Get index values based on condition
body: <p>I have a text file called data.txt containing tabular data look like this:</p>
  
  <pre><code>                        PERIOD
  CHANNELS    1      2      3      4       5 
  0         1.51   1.61   1.94   2.13   1.95 
  5         1.76   1.91   2.29   2.54   2.38 
  6         2.02   2.22   2.64   2.96   2.81 
  7         2.27   2.52   2.99   3.37   3.24 
  8         2.53   2.83   3.35   3.79   3.67 
  9         2.78   3.13   3.70   4.21   4.09 
  10        3.04   3.44   4.05   4.63   4.53
  </code></pre>
  
  <p>In the CHANNELS column are the channel numbers of an instrument and in the other 5 columns are the maximum energy that that particular channel can detect in periods 1, 2, 3, 4 and 5 respectively.</p>
  
  <p>I want to write a python code which gets the inputs: Period, Lower energy and Higher energy from the user and then gives out the channel numbers corresponding to the Lower energy and Higher energy for a given period. </p>
  
  <p>For example: </p>
  
  <pre><code>Enter the period:
  &gt;&gt;1
  Enter the Lower energy:
  &gt;1.0
  Enter the Higher energy:
  &gt;2.0
  #Output
  The lower energy channel is 0
  The higher energy channel is 6
  </code></pre>
  
  <p>This is what I have written so far: </p>
  
  <pre><code>import numpy as np
  import pandas as pd
  
  period = int(input('Enter the period: '))
  lower_energy = float(input('Enter the lower energy value: '))
  higher_energy = float(input('Enter the higher energy value: '))
  row_names = [0, 5, 6, 7, 8, 9, 10]
  column_names = [1, 2, 3, 4, 5] 
  data_list = []
  with open('data.txt') as f:
  lines = f.readlines()[2:]
  for line in lines:
      arr = [float(num) for num in line.split()[1:]]
      data_list.append(arr)
  df = pd.DataFrame(data_list, columns=column_names, index=row_names)
  print (df, '\n')
  print (df[period])
  </code></pre>
  
  <p>Help me add to this.</p>