Created
April 21, 2014 23:54
-
-
Save anxiousmodernman/11160597 to your computer and use it in GitHub Desktop.
How to import a CSV file in pandas
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# cd to a directory with a csv file in it. Any old csv file will do. | |
# run ipython and type these things at the interactive prompt, line by line: | |
>>> import pandas as pd | |
>>> data = pd.read_csv('some_csv.csv') # other arguments to read_csv are available to change the separator char, for example | |
>>> data | |
>>> data.keys # access the keys property of the DataFrame object | |
>>> len(data) # see the length of the DataFrame object | |
>>> data.some_column.sum() # get the sum of numeric-type columns | |
>>> data.some_column.count() # get the count of non-null values | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The >>> signifies the prompt, so don't type that. For instance, on line 4, just type