'Add strings to an array for reference

I have a df where pandas creates a list of every month between start and end. I want to now add strings and values to those months to create an easy reference ID to prices that would have the same reference code.

df['Cheat_start'] = df['Year'].astype(str) + df['StartMonth'].astype(str) +  
df['TimeOfUse'].astype(str)   

df_test = df.head(5)
display(df_test)

new_list_df = list(map(lambda x : list(range(x[0], x[1]+1)), df_test[['StartMonth','EndMonth']].values))

Output:

[[7, 8, 9, 10, 11, 12],
[7, 8, 9, 10, 11, 12],
[7, 8, 9, 10, 11, 12],
[9, 10, 11, 12],
[11, 12]]

I want each of these numbers from the outputs to replicate the image of the cheat for start month where I can use these combined values to reference something else. Here is a picture to understand.

 url

Desired output:

 [[ 72019PeakWE, 20198PeakWE, 20199PeakWE ,201910PeakWE ,201911PeakWE ,201912PeakWE], 
[72019PeakWE, 20198PeakWE, 20199PeakWE ,201910PeakWE ,201911PeakWE ,201912PeakWE],
[72019PeakWE, 20198PeakWE, 20199PeakWE ,201910PeakWE ,201911PeakWE ,201912PeakWE],
[20199PeakWE ,201910PeakWE ,201911PeakWE ,201912PeakWE], [201911PeakWE ,201912PeakWE]]

Any idea on how I would do this?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source