1

(My first ever StackOverflow question)

I'm trying to plot bitcoin's market-cap against the date using pandas and matplotlib in Python.

Here is my code:

%matplotlib inline
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

#read in CSV file using Pandas built in method
df = pd.read_csv("btc.csv", index_col=0, parse_dates=True)

Here are some details about the data frame: dataframe details

matplotlib code:

#Plot marketcap(usd)
plt.plot(df.index, df["marketcap(USD)"])
plt.show()

Result: Incorrect result

The plot seems to be more like scribbles that seem to move backwards. How could I fix this?

1
  • Looks like your data is not sorted by the date. Commented Jun 24, 2018 at 17:32

1 Answer 1

1

You can plot your Pandas Series "marketcap(USD)" directly using:

df["marketcap(USD)"].plot()

See the Pandas documentation on Basic Plotting

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.