Creating, Reading and Writing
Table of contents
import pandas as pd
Creating
pandas DataFrame
pd.DataFrame(data, index, columns, dtype)
- data : ndarray (structured or homogeneous), Iterable, dict, or DataFrame
- List-like of List-like : 각 List 는 row 를 나타냄
- List-like of Dict : 각 Dict 는 row 를 나타냄
- Dict 의 key : columns 의 이름
Dict 의 values : columns 의 성분
- Dict 의 key : columns 의 이름
- Dict of List-like : 각 List 는 column 을 나타냄
- index : Index or array-like
- columns : Index or array-like
- dtype : dtype, default None
pandas Series
pandas.Series 는 기본적으로 DataFrame 의 하나의 row data
pd.Series(data, index, name, dtype)
- data : array-like, Iterable, dict, or scalar value
- index : array-like or Index (1d)
- name : str, optional
- dtype : str, numpy.dtype, or ExtensionDtype, optional
Reading
pd.read_csv(filepath_or_buffer, index_col, header, names)
- filepath_or_buffer : str, path object or file-like object
- index_col : int, str, sequence of int / str, or False, optional, default None
- which columns to row label?
- header : int, list of int, None, default ‘infer’
- which rows to column names?
- names : array-like, optional
- explicitly pass column names
Writing
pd.DataFrame.to_csv(path_or_buf, encoding)
- path_or_buf : str, path object, file-like object, or None, default None
- encoding : str, optional
pd.DataFrame.to_excel(excel_writer, encoding)
- excel_writer : path-like, file-like, or ExcelWriter object
- encoding : str, optional