-3

I have a dataframe with 2 coulmn, i want to iterate through the column headers, use that value and add a string to it and use it as the name of a list.

rr

resampled=pd.DataFrame() resampled['RAT']=dd1['RAT'] resampled['SAT']=dd1['SAT'] rr=resampled-resampled.shift(1)

for ind, column in enumerate(rr.columns):

name=column+'stuck'
name=[]    
print(name)

I want to get 2 list with names RATstuck SATstuck

THank you!

tonyt
  • 1
  • 1
  • Indentation after the `for` loop? line: `name=[]` you are reinitializing the variable name into an empty list. Make some efforts on the code. – Mathieu Mar 27 '18 at 13:34
  • You can't _name_ a list. Lucky for you there is [namedtuple](https://docs.python.org/2/library/collections.html#collections.namedtuple) :) – zipa Mar 27 '18 at 13:35

1 Answers1

0

have you tried list comprehension?

[x+'stuck' for x in rr.columns]