Reputation: 231
I am trying to draw a line chart from the following data. On the x-axis, I want to show the year, on the y-axis, I want to show the population of different 'Borough'. Basically, I want to draw the population of all the boroughs throughout the years. I wrote the following code to transpose the data and draw the line graph. I am getting error- "no numeric data to plot". First figure is of the transposed data, second figure is of the original data
bar_plot = bar_plot.transpose()
bar_plot
bar_plot.columns = ['NYC Total Population', 'Bronx Population', 'Brooklyn Population' , 'Manhattan Population', 'Queens Population', 'Staten Island Population']
bar_plot.drop('Borough')
bar_plot.plot(kind = 'line', y = ['NYC Total Population', 'Bronx Population', 'Brooklyn Population' , 'Manhattan Population', 'Queens Population', 'Staten Island Population'])
Upvotes: 1
Views: 872
Reputation: 4921
There are no errors in your plot code. This error occurs if data type is category. Take care to convert and verify for numeric type using for ex.:
bar_plot = bar_plot.apply(pd.to_numeric)
bar_plot.dtypes
The following simplified code gives a lineplot:
import pandas as pd
bar_plot = pd.DataFrame({'NYC Total Population': [200, 400, 600], 'Staten Island': [30, 60, 90]}, index=[1950, 1960, 1970])
bar_plot.plot(kind = 'line', y = ['NYC Total Population', 'Staten Island'])
Upvotes: 1