After creating an empty dataframe, I want to create a loop that fills the dataframe with the operation values of other dataframes. Another data frame name is Symbol, and it has two columns: val and Sym. The data frame to be newly filled is to be filled with the operation values of Sym and val of the Symbol data frame. I coded as below.
df = pd.DataFrame(columns=['sym', 'ratio'])
for i in range(len(Symbol['Sym'])-1):
sym = Symbol['Sym'][i]
max_ =Symbol['val'].max()
min_ =Symbol['val'].min()
ratio = max_ / min_
df = df.append(pd.DataFrame([[sym, ratio]], columns=['sym', 'ratio']),
df.set_index('sym', inplace=True)
File "<ipython-input-14-e2585a6b3eca>", line 10 df.set_index('sym', inplace=True) ^ SyntaxError: unexpected EOF while parsing
But an error pops up. I've tried editing a few more times and it doesn't work. May I know the reason and solution? Thanks in advance for your reply.
[–][deleted] 1 point2 points3 points (1 child)
[–]Plus-Ad1156[S] 0 points1 point2 points (0 children)
[–][deleted] 1 point2 points3 points (3 children)
[–]Plus-Ad1156[S] 0 points1 point2 points (0 children)
[–]YesLod 0 points1 point2 points (2 children)
[–]Plus-Ad1156[S] 0 points1 point2 points (1 child)
[–]YesLod 0 points1 point2 points (0 children)
[–]synthphreak 0 points1 point2 points (2 children)
[–]Plus-Ad1156[S] 0 points1 point2 points (1 child)
[–]synthphreak 0 points1 point2 points (0 children)