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

Trying to apply example on my own data #16

Open
thebadguyfromstarwars opened this issue Apr 28, 2021 · 2 comments
Open

Trying to apply example on my own data #16

thebadguyfromstarwars opened this issue Apr 28, 2021 · 2 comments

Comments

@thebadguyfromstarwars
Copy link

As you can see above - the bold code is of my own making. I'm taking a column, predicted_stock_data[:,0], from a dataframe to use a the closing price. I then add the 'Date'. I can't grasp the problem with 'Date'.

res = predicted_stock_data[:,0]
des = pd.DataFrame(res, columns = ['Close'])
start = datetime(2018, 9, 29)
dates = pd.date_range(start, periods=100).to_pydatetime().tolist()
des['Dates'] = dates
res = trendet.identify_df_trends(df=des, column='Close')

with plt.style.context('classic'):
plt.figure(figsize=(20, 10))
ax = sns.lineplot(x=res['Date'], y=res['Close'])

labels = res['Up Trend'].dropna().unique().tolist()

for label in labels:
    sns.lineplot(x=res[res['Up Trend'] == label]['Date'],
                 y=res[res['Up Trend'] == label]['Close'],
                 color='green')

    ax.axvspan(res[res['Up Trend'] == label]['Date'].iloc[0],
               res[res['Up Trend'] == label]['Date'].iloc[-1],
               alpha=0.2,
               color='green')

labels = res['Down Trend'].dropna().unique().tolist()

for label in labels:
    sns.lineplot(x=res[res['Down Trend'] == label]['Date'],
                 y=res[res['Down Trend'] == label]['Close'],
                 color='red')

    ax.axvspan(res[res['Down Trend'] == label]['Date'].iloc[0],
               res[res['Down Trend'] == label]['Date'].iloc[-1],
               alpha=0.2,
               color='red')

plt.show()

err

@thebadguyfromstarwars
Copy link
Author

err2

Having this peculiar issue now.. hmm..

@kdfrmy
Copy link

kdfrmy commented Sep 3, 2021

use this DataFrame format
image

Date is the index, and its type shoud be date not str

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