Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error running process.py #5

Open
granthoff1107 opened this issue Feb 15, 2021 · 2 comments
Open

Error running process.py #5

granthoff1107 opened this issue Feb 15, 2021 · 2 comments

Comments

@granthoff1107
Copy link

granthoff1107 commented Feb 15, 2021

Process.py throws an error when running calculate_df

def calculate_df(df):
    data_df = df.filter(['tickers', 'score', 'sentiment'])

    tickers_processed = pd.DataFrame(df.tickers.explode().value_counts())

    tickers_processed = tickers_processed.rename(columns = {'tickers':'counts'})

    tickers_processed['score'] = 0.0
    tickers_processed['sentiment'] = 0.0

     for idx, row_tick in enumerate(tickers_processed.iloc):

at line:

for idx, row_tick in enumerate(tickers_processed.iloc):

Exception has occurred: NotImplementedError
ix is not iterable
File "C:\Users\MyUser\Desktop\NLP\trading-bot-base\tickerrain\process.py", line 113, in calculate_df
for idx, row_tick in enumerate(tickers_processed.iloc):
File "C:\Users\MyUser\Desktop\NLP\trading-bot-base\tickerrain\process.py", line 152, in processed_df
return calculate_df(df), calculate_df(df_3), calculate_df(df_1)
File "C:\Users\MyUser\Desktop\NLP\trading-bot-base\tickerrain\process.py", line 157, in processing_last
last_processed, last_processed_3, last_processed_1 = processed_df()
File "C:\Users\MyUser\Desktop\NLP\trading-bot-base\tickerrain\process.py", line 169, in
asyncio.run(processing_last())

@granthoff1107
Copy link
Author

Not sure if this is related to my package versions or python version but I fixed this issue by using the following code instead:

for idx, row_tick in enumerate(tickers_processed.itertuples(), 1):
    upd_row_sent = row_tick.sentiment
    upd_row_score = row_tick.score
    for row_data in data_df.itertuples():
        if(row_tick.Index in row_data.tickers):
            upd_row_sent += row_data.sentiment['compound'] / row_tick.counts
            upd_row_score += int(row_data.score) / row_tick.counts
            tickers_processed.set_value(row_tick.Index, 'sentiment', upd_row_sent)
            tickers_processed.set_value(row_tick.Index, 'score', upd_row_score)

@GonVas
Copy link
Owner

GonVas commented Feb 17, 2021

I am redoing all of the process, to be faster, the new version will be better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants