import pandas as pd
def test_run():
for symbol in ['nugt', 'soxs']:
for stat in ['max', 'min', 'mean']:
print(f"{stat} Close")
print(symbol, get_stat(symbol, stat))
def get_stat(symbol, stat):
df = pd.read_csv(f"{symbol}.csv")
return getattr(df['close'], stat())
if __name__ == "__main__":
test_run()
I am trying to open up an 2 excel files (soxs.csv and nugt.csv) , look at the column "close" and find the max, min, mean in the "close" column for each file.
The result I am getting is "TypeError: 'str' object is not callable"
. But I am calling it with attributes that should run just trying to do it with less code by using a loop. Any suggestions on how to get around this?