0

I have a large df where I would like to assign the values of variables to the 'frequency' column based on the values of the 'period' column and the 'tier' column.

This is a simplified version of the dataframe:

enter image description here

freq1= 1
freq2= 2
freq2= 2
freq2= 4
freq2= 5
freq2= 6
freq2= 7
freq2= 4

what I would like to do, is apply the value of the variables to the frequency column. For example, if df.period == 1 & df.tier == 1 then df['frequency'] = freq1

Please do not pay attention to the values of each variable, this is a crude representation of the real problem. The principle however, remains the same.

Community
  • 1
  • 1
LeoGER
  • 355
  • 1
  • 8
  • 2
    [numpy select](https://docs.scipy.org/doc/numpy/reference/generated/numpy.select.html) might help. Also, it would be helpful if u shared data, not pics, so folks here can test their code as well. In addition, add what u have tried, and where u failed, if u did – sammywemmy Apr 26 '20 at 10:13
  • Thank you for your comment, I believe you put me one the right track. Apologies for asking, but how would one share the data if not by a screenshot? is it possible using jupyter nb? – LeoGER Apr 26 '20 at 10:31
  • 1
    Kindly Read this [guide](https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples) for guidance on how to do it – sammywemmy Apr 26 '20 at 10:37

0 Answers0