0

I am wondering, if there is a possibility to do the following more efficient:

mins = argrelextrema(series, np.less)[0]
for i in mins:
    courses.loc[i, "MinMax"] = "Min"

Thank you for your help!

pault
  • 41,343
  • 15
  • 107
  • 149
SevenOfNine
  • 630
  • 1
  • 6
  • 25
  • 2
    Have you tried `courses.loc[mins, "MinMax"] = "Min"`? – pault Feb 02 '18 at 15:29
  • https://stackoverflow.com/questions/31569384/set-value-for-particular-cell-in-pandas-dataframe-with-iloc – BENY Feb 02 '18 at 15:31
  • @pault thank you, unfortunately, this leads to a KeyError. – SevenOfNine Feb 02 '18 at 15:34
  • @Wen unfortunately I do not see that there is an array or a list used to adress certain rows. Please correct me if I am wrong. – SevenOfNine Feb 02 '18 at 15:34
  • df.loc[np.array([1,3,4]),'MinMax']='Your value' – BENY Feb 02 '18 at 15:38
  • 1
    Can you provide a [mcve] so we can try to recreate your issue? – pault Feb 02 '18 at 15:39
  • Ok. the Problem was, that I have not created the column before - this is why df.loc[np.array([1,3,4]),'MinMax']='Your value' gave me a KeyError. I have initialized the column with courses['MinMax'] = 0. Thank you for the help! – SevenOfNine Feb 02 '18 at 15:45

0 Answers0