pandas is a fast, powerful, flexible and easy to use open source data analysis and manipulation tool, built on top of the Python programming language.
DataFrame
과 Series
이해 필요How to load Pandas
import pandas as pd
Series
1차원 자료구조 1차원 리스트와 유사하지만 Series는 index에 이름을 부여할 수 있음
DataFrame
2차원 자료구조 행 (row) 과 열(column) 으로 이루어 짐
Series is a one-dimensional labeled array capable of holding any data type (integers, strings, floating point numbers, Python objects, etc.).
The axis labels are collectively referred to as the index
- How to create a Series
s = pd.Series(data, index=index, name="name")
- data
- python dictionary - an ndarray - a scalar Value
- index
- 인덱스를 지정하지 않으면, 0을 시작으로 정수로 자동으로 생성 됨 - 반면에, data에 딕셔너리를 넣으면 key 값이 index로 들어감 => 따로 지정해주지 않아도 됨
- Name
name = "" 로 시리즈에 이름을 부여할 수 있음 => DataFrame 에선, column 하나를 셀렉하여 이름을 부여할 수 있음
DataFrame is a 2-dimensional labeled data structure with columns of potentially different types.
- How to create a DataFrame
d = pd.DataFrame(data, index=index, columns=columns, dtype=dtype)
- data
- Dict of 1D ndarrays, lists, dicts, or Sereis - 2D numpy.ndarray - Structured or record ndarray - A Series - Another DataFrame
- index
- 인덱스 지정하지 않으면, 0을 시작으로 정수로 자동으로 생성 됨 - 인덱스를 지정하려면, index = [] 로 설정하면 됨
- columns
- data에 딕셔너리 형태를 넣으면, key 값이 컬럼명이 됨 - columns = [] 에 넣어줘도 됨
- dtype
- 데이터 타입을 지정할 수 있음 - dtype = float (정수를 넣어도 실수형태로 데이터 만들어 짐)