This is a draft cheat sheet. It is a work in progress and is not finished yet.
IMPORTING DATA
pd.read_csv(filename) |
# From a CSV file |
pd.read_table(filename) |
# From a delimited text file (like TSV) |
pd.read_excel(filename) |
# From an Excel file |
pd.read_sql(query, con_object) |
# Reads from a SQL table/database |
pd.read_json(json_string) |
# Reads from a JSON formatted string, URL or file. |
pd.read_html(url) |
# Parses an html URL, string or file and extracts tables to a list of dataframes |
pd.read_clipboard() |
# Takes the contents of your clipboard and passes it to read_table() |
pd.DataFrame(dict) |
# From a dict, keys for columns names, values for data as lists |
|
|
EXPLORING DATA
df.shape() |
# Prints number of rows and columns in dataframe |
df.head(n) |
# Prints first n rows of the DataFrame |
|