pythonpandasnumpyweather

How to plot a line graph of an array from a dataframe?


I have a dataframe, test, that contains winter temperatures since 1951 for a city. I want to plot the temperatures contained in the column called p95_annual but when I try to do that using plt.plot(test.p95_annual.values) I get the following: enter image description here Here's what test, wintermean, and test.wintermean.values looks like: enter image description here How can I plot this temperature data?


Solution

  • You have one single row in your DataFrame which has a string. You need to parse the individual values from this string before plotting it:

    data = list(map(int, test.at[124,"p95_annual"][1:-1].split()))
    
    >>> plt.plot(data)
    

    enter image description here