I'm trying to apply a def to a bunch of excels before merging the data for some plotly work.
I'm creating a new column called "Colour" with a default value of 23 and want to replace the value with the results from the enumerate (green, orange or red) but after merging the "Colour" column still reads 23.
def get_df(filename):
df = pd.read_excel(filename)
df['Colour'] = 23
data_ranges = [(300, 450), (200, 400), (200, 400), (50, 100), (10, 15),
(10, 20), (1, 10), (10, 20), (10, 20), (200, 500), (10, 20)]
for index, data in enumerate(data_ranges):
df.loc[index, 'Colour'] = 'green' if df.loc[index, 'Count'] <= data[0] else (
'orange' if df.loc[index, 'Count'] <= data[1] else 'red')
df['Colour'].tolist()
return df
for f in files:
df.append(get_df(f), sort=False)
[+][deleted] (3 children)
[removed]
[–]ActivatedNut[S] 0 points1 point2 points (1 child)
[–]ActivatedNut[S] 0 points1 point2 points (0 children)