The Next Level of Pandas read_csv( )
9 underused parameters of the well know Pandas’ read_csv() method.
We all know Pandas’ (probably) most used method pd.read_csv()
.
But do you know it has a lot (and I mean it!) of cool features for you to start transforming your data during the loading?
In this article, I will share 9 of those tricks, so you can add them to your Data Scientist toolbox and achieve the next level of exploratory data analysis.
Install and Load Pandas
Like any regular library in Python, you can install using pip and then import the pack to the session.
pip install pandas
import pandas as pd
1. Change the separator / delimiter
The method is read_csv()
, but you can actually pull tab separated (tsv) or a file separated by any other delimiter. Just use the parameter delimiter='xx'
.
# Loading with sep or delimiter parameter for a file separated by --
df = pd.read_csv('/content/sample--.csv', delimiter='--',
engine='python')