0

I have next code:

listTest = ["ration","hello","exclamation"]

word=['masha[a-z]*']
channels=['BOOMERANG','NICK']

targets=['KIDS','BOYS']
l=[]
for j in range(22):                                                         
    df=fran_tvp[fran_tvp.Año.isin([año]) & fran_tvp.Channel.isin(channels)&fran_tvp.Week.isin([j])]  
    l.append(df[['TimeBand',targets]].set_index('TimeBand').rename(columns={'TimeBand' : 'TimeBand' + 
    str(j)}))

df=pd.concat((l),axis=1).reset_index()
df=df.iloc[:, [0,6,10,14,19,21]]

df.columns = [' ','20-ene','20-feb','20-mar','20-abr','20-may']

The problem is that with the lists it does not make me search for targets, is there any function to use with the lists?
Since if I use targets = 'KIDS' it works.

4

1 回答 1

1

You probably need add to list.

Ex:

l.append(df[['TimeBand'] + targets].set_index('TimeBand').rename(columns={'TimeBand' : 'TimeBand' + str(j)}))
于 2020-07-23T04:13:40.273 回答