When I use interpolation (or fillna, or any other method of generating some fake data) in Pandas, I would like this to show in my plots. Ideally, I would like to use a different marker for these points in the plot. For regular points I want to use filled circles ('o'), for fake data I want to use crosses ('x').
Of course, I would like to do this with a nice Pythonic oneliner.
One further complication is that I want to use the subplots option in the plot function to plot all my columns at once. I'm hoping manipulating the subplots with Matplotlib voodoo is not necessary, though at this point that's the only option I can think of.
The data I'm using is something like the following (put into file 'meterstanden.ssv'):
datum tijd gas[m^3] electra1[kWh] electra2[kWh] water[m^3]
2015-03-06 09:00 4000.318 10300 9000 300.0
2015-03-24 20:10 4020.220 - 10003 -
2015-08-02 11:15 4120.388 10500 11000 350.5
And here is the script I'm using to process it:
import matplotlib.pyplot as plt
import pandas as pd
df = pd.read_table("meterstanden.ssv", delim_whitespace=True,
parse_dates=[[0, 1]], index_col=0, na_values=['-'])
df.interpolate(method='time').plot(subplots=True, layout=(2, 2),
figsize=(14, 10), marker='o')
plt.show()
I want the - entries in the table to be plotted with cross-markers.
Aucun commentaire:
Enregistrer un commentaire