Using the pandas module to read and process data
Pandas is a set of tools for easy manipulation and analysis of tabular data. Among these tools is an object for representing and manipulating tabular data called a dataframe. With a dataframe, it is possible to express row-wise and column-wise operations to be performed on the data. Pandas can simplify the process of working with data considerably, requiring fewer lines of code and making the process more intuitive.
Counting the total road length in 2011 revisited
In this next demonstration, you will approach the same problem of enumerating the road length--this time using pandas. To start off with, create a file called pandas_intro.py
that import the pandas
module as follows:
import pandas
Reading CSV data using the pandas
module is quite simple. Pandas combines the process of opening a file with the process of reading and parsing the data. To read a CSV file using the pandas
module, you can use the pandas.read_csv()
function. The pandas.read_csv...