title: Slicing DataFrame by duplicate period indexes in Pandas
body: <p>I Slice DataFrame by period indexes of Pandas, when
  the period indices are unique, the slicing is OK,
  But when the period indices are duplicate, the slicing will cause exception:</p>
  <h1>TypeError: Cannot compare type 'Period' with type 'int',</h1>
  <p>The following is my code:</p>
  <pre><code>import pandas as pd
  from pandas import DataFrame
  df=DataFrame(data=[1,2,3,4,5],columns=[&quot;value&quot;])
  #generate unique period index for dataframe
  index=pd.PeriodIndex([2001,2002,2003,2004,2005],freq=&quot;A&quot;)
  df.index=index;
  df.loc[pd.Period(2002):pd.Period(2004)] #is ok
  
  #generate duplicate period index for dataframe
  index=pd.PeriodIndex([2001,2001,2003,2004,2005],freq=&quot;A&quot;)
  df.index=index;
  df.loc[pd.Period(2002):pd.Period(2004)]
  #TypeError: Cannot compare type 'Period' with type 'int'
  </code></pre>