Skip to content

Instantly share code, notes, and snippets.

@vikas-git
Created September 10, 2019 06:01
Show Gist options
  • Save vikas-git/c6bcd408e6239f30384d5aaebb00d6bd to your computer and use it in GitHub Desktop.
Save vikas-git/c6bcd408e6239f30384d5aaebb00d6bd to your computer and use it in GitHub Desktop.
Some tricks of pandas for working more fast
# source: https://towardsdatascience.com/10-python-pandas-tricks-that-make-your-work-more-efficient-2e8e483808ba
pd.read_csv('file_name.csv', nrows = 5, usecols=['c1', 'c2'], dtype = {‘c1’: str, ‘c2’: int, …})
argument
* nrows = 5 (it will select only 5 rows from dataframe)
* usecols (select certain columns on df creation)
* dtype (specify col data type)
*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment