Skip to content

Instantly share code, notes, and snippets.

@SolClover
Last active August 8, 2020 03:45
Show Gist options
  • Save SolClover/9f3111e73824ca9cb053b4ed631a7d4f to your computer and use it in GitHub Desktop.
Save SolClover/9f3111e73824ca9cb053b4ed631a7d4f to your computer and use it in GitHub Desktop.
Read in CSV to Pandas DataFrame
# Import csv into a new Pandas DataFrame
new_df=pd.read_csv('C:/temp/test.csv')
# You can also specify which columns you want to read in with usecols by either
# specifying their name or position
# Using column names
new_df=pd.read_csv('C:/temp/test.csv', usecols=['Name','Surname', 'Height', 'Age'])
# Using column positions
new_df=pd.read_csv('C:/temp/test.csv', usecols=[0,1,2,3])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment