#πŸ”’ I cant append tuple to list

9 messages Β· Page 1 of 1 (latest)

viscid wadi
#

I want to use list.append(tuple)

But I get error:

Traceback (most recent call last):
File "c:\Users\janju\OneDrive\Desktop\Learning_Trading_Bot\Mean_reversion_bot\data_processing.py", line 30, in <module>
non_stationary_symbols.append[result]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
TypeError: 'builtin_function_or_method' object is not subscriptable

distant quailBOT
#

@viscid wadi

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

#

Hey @viscid wadi!

Please edit your message to use a code block

You are using the wrong character instead of backticks. Use ```, not '''.

Also, add a py after the three backticks.

```py
print('Hello, world!')
```

This will result in the following:

print('Hello, world!')```
untold bridge
viscid wadi
#

import pandas as pd
from statsmodels.tsa.stattools import adfuller
import pickle

def stationary_test(df, symbol):
    time_series = df['Close']
    result = adfuller(time_series)
    
    return (symbol, result[1])



with open("stock_data.pkl", "rb") as f:
    dic_combined_data = pickle.load(f)

df_symbols = pd.read_csv("index-holdings-xlp.csv")
df_symbols = df_symbols.Symbol


non_stationary_symbols = []
stationary_symbols = []
for symbol in df_symbols:
    data = dic_combined_data[symbol]
    result = stationary_test(data, symbol)

    if result[1] < 0.05:
        stationary_symbols.append[result]
    elif result[1] >= 0.05:
        non_stationary_symbols.append[result]
    
print(non_stationary_symbols)

#

ouuu i see, why did i even put square brackets

#

thx

distant quailBOT
#
Python help channel closed for inactivity

This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.