0

How do I plot DataFrame columns against each other ignoring indices? e.g.

Let a DataFrame df1 be as follows:

   x   y
0  0   5
1  1  10
2  2  15
3  3  20
4  4  25

I've tried:

import matplotlib.pyplot as plt
import pandas as pd
df1.plot()
df1.plot(df1['x'],df1['y'])

The first case yielding two plots, one for each column in the ordinate and the index as abcissa, the second producing an out of bounds indexing error.

1 Answer 1

1

You could:

df1.set_index('x').plot()
Sign up to request clarification or add additional context in comments.

1 Comment

perfect, i feel dumb now

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.