In this recipe, we show how to load a dataset into Python. In order to show the entire pipeline—including working with messy data—we apply some transformation to the original dataset. For more information on applied changes, please refer to the accompanying GitHub repository.
Loading data and managing data types
How to do it...
Execute the following steps to load a dataset into Python.
- Import the libraries:
import pandas as pd
- Preview a CSV file:
!head -n 5 credit_card_default.csv
The output looks like this:
- Load the data from the CSV file:
df = pd.read_csv('credit_card_default.csv', index_col=0,
na_values='')
The DataFrame has 30,000 rows and 24 columns.
- Separate...