1

I have the following dataframe:

          date      high      low  Sentiment
0   2018-02-01  10288.80  8812.28         -4
1   2018-02-02   9142.28  7796.49         -1
2   2018-02-03   9430.75  8251.63         -2
3   2018-02-04   9334.87  8031.22          7
4   2018-02-05   8364.84  6756.68         -4
5   2018-02-06   7850.70  6048.26        -12
6   2018-02-07   8509.11  7236.79        -11
7   2018-02-08   8558.77  7637.86        -17
8   2018-02-09   8736.98  7884.71          9
9   2018-02-10   9122.55  8295.47         -4
10  2018-02-11   8616.13  7931.10          4
11  2018-02-12   8985.92  8141.43          0
12  2018-02-13   8958.47  8455.41         -3
13  2018-02-14   9518.54  8599.92         -4

My final goal is to represent all the values ​​from the dataframe but I can't see the dates on the x-axis. I used this code:

df = Original_df [['date', 'high', 'low', 'Sentiment']].copy()
ax = df.plot(secondary_y='Sentiment')
ax.set_yscale('linear')
plt.show()

enter image description here

update: even in this way I don't see the dates. What am I doing wrong?

df = Original_df[['date', 'high', 'low', 'Sentiment']].copy()
    df = df.set_index('date')
    ax = df.plot(secondary_y='Sentiment')
    ax.set_yscale('linear')
    plt.show()

enter image description here

5
  • If you want your date column to be on the x axis you have to make it the index of your dataframe, try df.set_index('date', inplace=True) and then df.plot... Commented Mar 14, 2019 at 22:30
  • Have you though about putting df.plot(label='date')? Commented Mar 14, 2019 at 22:34
  • thanks for the help but the desired values ​​do not appear Commented Mar 14, 2019 at 22:38
  • @PabloPicciau sorry, I meant to saydf.plot(x='date, y='high') but I guess you'll need 3 plots. Commented Mar 14, 2019 at 22:43
  • instead of numbers I only see the word "date" Commented Mar 14, 2019 at 22:50

1 Answer 1

1

This should do the trick:

df = df.set_index('date')
ax = df.plot(secondary_y='Sentiment')

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.