0

I have created a csv data like:csv image link to csv data: https://1drv.ms/x/s!AiBcPojQRu1SgRw-uiiRIQ0LhXYi?e=uEU9d5

and when I print the csv data it shows like this : printed using pandas code I used

and when I plot the data using matplotlib it shows: error on plotting can anyone help me with this?

5

1 Answer 1

1

First Read csv file with header and here are also sub header so need both headers and delete unwanted unmamed which create onself instead of blank space. and then possible to plotting.

import pandas as pd
import matplotlib.pyplot as plt

#read csv file
covid  = pd.read_csv('D:/kerala.csv',header=[1,2],index_col=[0])
print(covid)

#use Header and Subheader
a = covid.columns.get_level_values(0).to_series()
b = a.mask(a.str.startswith('Unnamed')).ffill().fillna('')
covid.columns = [b, covid.columns.get_level_values(1)]
print (covid)

#plotting
covid.plot()
plt.show()

HOPE IT HELP YOU

Sign up to request clarification or add additional context in comments.

2 Comments

It did worked but is it possible to the output like this?: prnt.sc/SPyJr_t9V4Xd
covid = pd.read_csv('D:/kerala.csv',header=[1,2],index_col=[0]),,,,Just use this statement instead of previous it will work garph with district name.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.