Basic Matplotlib Scatter Plot From Pandas DataFrame

matplotlib, pandas, python, python-2.7

Solution

Strange. That ought to work.

Running this

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

dataframe = pd.DataFrame({'Col': np.random.uniform(size=1000)})
plt.scatter(dataframe.index, dataframe['Col'])

spits out something like this

Maybe `quit()` and fire up a new session?

Problem

How to make a basic scatter plot of column in a DataFrame vs the index of that DataFrame? Im using python 2.7. ``` import numpy as np import pandas as pd import matplotlib.pyplot as plt dataframe['Col'].plot() plt.show() ``` This shows a line chart of 'Col' plotted against the values in my DataFrame index (dates in this case). But how do I plot a scatterplot rather than a line chart? I tried ``` plt.scatter(dataframe['Col']) plt.show() ``` But `scatter()` requires 2 arguments. So how do I pass the series `dataframe['Col']` and my dataframe index into `scatter()` ? I for this I tried ``` plt.scatter(dataframe.index.values, dataframe['Col']) plt.show() ``` But chart is blank.

Original source