Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Data Science by (18.4k points)

I am trying to work on the time_series_2019-ncov-Confirmed.csv

dataset. I wanted to plot only the conformed cases in China, Italy, Germany, Iran, and USA.

I have coded as shown below, can anyone suggest me how do I achieve my expected results.

import numpy as np

import pandas as pd

import csv 

file = r'C:\Users\Tiago\Desktop\Senior Year - 2019.2020\ME 130\Coronovirus Datasets\time_series_2019-ncov-Confirmed.xlsx'

data = pd.ExcelFile(file)

print(data.sheet_names)

['Worksheet']

df = data.parse('Worksheet')

df.info

df.head(400) 

1 Answer

0 votes
by (36.8k points)

You need not convert the data set into excel format. Since we have the data set in CSV format you can use read_csv() to read the CSV file. Then you can use the matplotlib.pyplot for plotting the conformed cases in different regions.

This is the code for selecting the individual countries.

import pandas as pd

data = pd.read_csv('time_series_covid_19_confirmed.csv')

countries = ['China', 'Italy', 'Germany', 'Iran', 'USA']

filtered_data = data[data['Country/Region'].isin(countries)] 

If you want to gain knowledge in data science from the scratch then click on the link data science course.

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...