Stack Overflow Asked by KLM on December 5, 2021
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.
You probably need add to list.
Ex:
l.append(df[['TimeBand'] + targets].set_index('TimeBand').rename(columns={'TimeBand' : 'TimeBand' + str(j)}))
Answered by Rakesh on December 5, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP