Error when plotting date values with matplotlib [closed]

0

I'm testing with Pandas and matplotlib. The first column of the Excel are dates, format (dd / mm / yy). Reading the Excel sheet with Pandas presents me:

0                Fecha      Valor
1  2017-09-11 00:00:00      44.42
2  2017-09-08 00:00:00      44.17
3  2017-09-07 00:00:00      43.86
4  2017-09-06 00:00:00      43.91

When trying to graph with matplotlib it gives me the error KeyError: "Date" How can I get the date imported by Pandas to have the date format and thus be able to graph dates - values?

    
asked by efueyo 17.09.2017 в 19:37
source

1 answer

0

Problem solved using xlrd

#!/usr/bin/env python

- - coding: utf-8 - -

import pandas as pd import xlrd import matplotlib.pyplot as plt

excel file

filename = 'quotes.xlsx'

reading the excel file

df = pd.read_excel ("quotes.xlsx") print df.head () # print the first 5 elements

shows the graph

fig, ax = plt.subplots () ax.plot (df ['Date'], df ['Value']) plt.show ()

    
answered by 21.09.2017 / 15:11
source