-1

is anyone familiar with if...conditions in pandas and can help me with a petite question for a beginner? right now I have this:

tmy_data.loc[tmy_data['elevation of sun'] <= 10, 'DNI'] = 0

But instead of setting the'DNI' to zero when 'elevation of sun' is less then 10, I want it to decrease to 80% Probably its not that complicated...but I still have no idea my try just ended in decreasing the whole dataframe instead of the single value

  • 1
    Welcome to Stackoverflow. Please take the time to read this post on [how to provide a great pandas example](http://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples) as well as how to provide a [minimal, complete, and verifiable example](http://stackoverflow.com/help/mcve) and revise your question accordingly. These tips on [how to ask a good question](http://stackoverflow.com/help/how-to-ask) may also be useful. – jezrael Apr 19 '21 at 07:29

1 Answers1

1

If you want to save to the existing column 'DNI'

tmy_data.loc[tmy_data['elevation of sun'] <= 10, 'DNI'] = tmy_data['DNI']*0.8

If you want to save to a new column 'DNI_new'

tmy_data.loc[tmy_data['elevation of sun'] <= 10, 'DNI_new'] = tmy_data['DNI']*0.8
imdevskp
  • 2,103
  • 2
  • 9
  • 23