0

I have a multi indexed file with values such as these

How could I plot a dataframe that has separate lines for each symbol in the same graph?

3
  • There are all symbol unique? Commented Sep 29, 2019 at 5:06
  • No, it repeats MSFT, GOOG, AAPL, MSFT, GOOG, APPL, etc Commented Sep 29, 2019 at 5:17
  • OK, so use second solution. Commented Sep 29, 2019 at 5:18

1 Answer 1

1

I believe you need pivot for all unique symbol values :

df1 = df.pivot(index='4.timestamp', columns='1.symbol', values='2.price')

If possible duplicated is becessary aggregate by DataFrame.pivot_table:

df1 = df.pivot_table(index='4.timestamp', columns='1.symbol', values='2.price', aggfunc='mean')

and then plot by DataFrame.plot:

df1.plot()
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.