title: Indexing in Function, Pandas
body: <p>I work with pandas dataframes and want to create a function with indexing.</p>
  <pre><code>def func(L,ra,N):
  
      
  
      df_N = df[T_N].diff() 
      df[T_N] = df[T_N].iloc[df_N.index.min():df_N.index.max()]
      df[T_N] = df[T_N].mean()
  
      Value = [L,df[TR[0]].iloc[1]-(df[T_N[0]].iloc[1]-df[T_N[0]].iloc[1]),1]
      return Value 
  </code></pre>
  <p>For the line</p>
  <pre><code>df[T_N] = df[T_N].iloc[df_N.index.min():df_N.index.max()]
  </code></pre>
  <p>The error</p>
  <pre><code>TypeError: cannot do positional indexing on Int64Index with these indexers [nan] of type float
  </code></pre>
  <p>occurs. Does anyone know a way how I can avoid that? Is it even possible to do it that way? It works at other lines, just this one seems to be a problem.</p>