os
module.import os
os.getcwd()
or os.get_current_working_directory()
displays the current file system location.os.chdir()
to change the directory:os.chdir('kaggle')
(moves one level up from kaggle/working
to kaggle
).os.listdir()
or os.listdir()
lists files and folders in a directory.kaggle/working
to kaggle
.input
folder.input/titanic
to find train.csv
, gender_submission.csv
, and test.csv
.pandas.read_csv()
function.import pandas as pd
pd.read_csv('input/titanic/train.csv')
.head(6)
displays the first six rows of the DataFrame.pd.read_table()
function.sep
argument.pd.read_table('file.tsv')
pd.read_table('file.txt', sep='-')
(if data is separated by hyphens).'\t'
to represent a tab character in the sep
argument.pd.read_excel()
function.draft = pd.read_excel('input/draft2015/draft.xlsx', sheet_name='draft2015')
.head()
displays the first few rows of the DataFrame.pd.read_csv()
or pd.read_excel()
to load the downloaded file.pd.read_clipboard()
function.df = pd.read_clipboard()
pd.read_html()
function.html5lib
package..to_csv()
method on a DataFrame.draft.to_csv('draft_save.csv')
draft
DataFrame to a CSV file named 'draft_save.csv' in the current working directory.os.listdir()
to confirm the file has been created.