0
x =df.loc[df['Company'] == 'Amazon']['Close'].mean()
y =df.loc[df['Company'] == 'Facebook']['Close'].mean()
z = df.loc[df['Company'] == 'Twitter']['Close'].mean()
t = df.loc[df['Company'] == 'Apple']['Close'].mean()
u = df.loc[df['Company'] == 'Google']['Close'].mean()
mean_list = [x,y,z,t,u] 

Output:

 [120.92017715033082, 221.07015915522499, 41.194891296501545, 95.73207150015942, 85.46766954760089]

So I am trying to aggregate the mean for these five company stocks based on a single data frame. Is there a for loop or function I can make to loop through each specific company in the data frame. Thanks

J Stizzy
  • 1
  • 1

0 Answers0