Pandas is a Python Data Analysis Library. It allows you to play around with data and perform powerful data analysis.
In this example I will show you how to read data from CSV and Excel files in Pandas. You can then save the read output as in a Pandas dataframe. The sample data used in the below exercise was generated by https://mockaroo.com/.
In [14]:
import pandas as pd
In [15]:
csv_data_df = pd.read_csv('data/MOCK_DATA.csv')
Preview the first 5 lines of the data with .head()
to ensure that it loaded.
In [16]:
csv_data_df.head()
Out[16]:
You will need to pip install xlrd
if you haven't already. In order to import data from Excel.
In [17]:
import xlrd
excel_data_df = pd.read_excel('data/MOCK_DATA.xlsx')
In [18]:
excel_data_df.head()
Out[18]:
Image Courtesy of jballeis (Own work) CC BY-SA 3.0, via Wikimedia Commons