businesstoe
businesstoe

Reputation: 13

How to draw time series from CSV file in Python

my CSV file is below:

Entity Code Year Total tax revenue (% of GDP) (ICTD (2021))
Afghanistan AFG 2003 2.512631
Afghanistan AFG 2004 4.07617
Afghanistan AFG 2005 4.668273
Afghanistan AFG 2006 6.061553
Afghanistan AFG 2007 6.174382
Afghanistan AFG 2008 8.673146
Afghanistan AFG 2009 9.559737

Above is my table, could you please tell me how to draw the time series from this CSV file? or give me some hints on this. Thank you very much!

Upvotes: 0

Views: 2322

Answers (1)

Avimsh
Avimsh

Reputation: 151

In order to draw time series from CSV file, first upload your data into python using 'pandas' 'Data Frame' and then plot figures/graphs of your data using 'matplotlib'.

import pandas as pd
import matplotlib.pyplot as plt

path = #enter the path of your csv file
df = pd.read_csv(path+'\data.csv')

df.plot(x='Year', y='Total tax revenue (% of GDP) (ICTD (2021))')

The code above will produce the following plot: enter image description here

For more information and examples you can look here, the visualization section of 'pandas'.

Upvotes: 3

Related Questions