0

I am trying to slice the array up when using the std function to only use part of it. That part being 1:t, as t is an integer that grows with each iteration of the for loop. Y is my pandas dataset and the column is 'TempK' which is specified as the column parameter. Is there a limit on much you can slice as the dataset is quite big or is it something else?

def calc_std(t, y, column):
    deviationPrediction = np.std(y.loc[1:t, [column]])
    return deviationPrediction

The error I receive is this:

Traceback (most recent call last): File "C:\Users\Kabla\Anaconda3\envs\condaEnv\Lib\site-packages\pandas\core\indexes\base.py", line 2657, in get_loc return self._engine.get_loc(key) KeyError: 1

Henry Ecker
  • 34,399
  • 18
  • 41
  • 57

1 Answers1

1

From the docs for loc:

note that 5 is interpreted as a label of the index, and never as an integer position along the index

Henry Ecker
  • 34,399
  • 18
  • 41
  • 57
luca.vercelli
  • 898
  • 7
  • 24