1

my simple code:

import pandas as pd
df = pd.DataFrame('data')

print(type(df))
print(df.columns)
print(df.head())

output:

<class 'pandas.core.frame.DataFrame'>
Index(['Value'], dtype='object')
             Value
Date              
2010-03-31  965.95
2010-04-01  974.99
2010-04-06  963.82
2010-04-07  968.23
2010-04-08  972.51

my question is, how can i access Date column? I would like to use it for matplot Y axis:

from matplotlib import pyplot as plt

plt.scatter(x, y = df['Date']))

The problem is, I can't access it. Thanks

1 Answer 1

2

Let's try:

df.index = pd.to_datetime(df.index)

plt.scatter(df['Value'],df.index)

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.