설치
windows : 설치 후 터미널 재실행 필요
powershell - ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
MacOS/Linux
curl -LsSf https://astral.sh/uv/install.sh | sh
최신 버전 업데이트
uv self update
주요 명령어
uv venv [가상환경 경로] [가상환경 이름] [--python=python버전]source .[가상환경 이름]/bin/activate 실행uv pip install 패키지명Pandas 판다스
개요
Series
Series 생성
pd.Series(1차원 iterable[, index=[인덱스값]])
# 입력
data = [0, 10, 20, 30, 40, 50, 60]
pd.Series(data)
# 출력값
0 0
1 10
2 20
3 30
4 40
5 50
6 60
dtype: int64
index 변경
[Series 데이터].index = list("index명")[Series 데이터].rename({"기존 index":"바꿀 index"Series 안의 원소 접근
Indexing
Series.iloc[순번]Series[index 이름] 또는 Series.loc[index 이름]Series[[index 이름 또는 순번]]Slicing
Series[start index : stop index : step]원소 단위 연산
index_name = ['국어', '영어', '수학', '과학']
s1 = pd.Series([80, 90, 100, 50], index=index_name)
s2 = pd.Series([100, 50, 80, 100], index=index_name)
s3 = pd.Series([1, 2, 3, 4])
result = s1 **2
result
# 출력 결과
국어 6400
영어 8100
수학 10000
과학 2500
dtype: int64
Series 주요 method
| method | 기능 |
|---|---|
| head([정수]) | 원소 개수를 앞에서부터 정수만큼 조회, 정수 미입력 시 기본 조회 개수 5개 |
| index | index명 조회 |
| shape | 행, 컬럼 개수 조회 |
| size | 원소 개수 조회 |
| dtype | 데이터 타입 조회 |
| astype(데이터 타입) | ()데이터 타입으로 변경 |
| isin([list] | Series의 원소가 list 안의 값들 중 하나와 같은지 여부에 따라 True/False 반환 |
| sort_values() | 원소 개수를 뒤에서부터 정수만큼 조회, 정수 미입력 시 기본 조회 개수 5개 |
| sort_index() | 원소 개수를 뒤에서부터 정수만큼 조회, 정수 미입력 시 기본 조회 개수 5개 |
| value_counts() | 고유한 값의 빈도수 조회, nomalize=True로 지정할 시 상대 빈도수 반환 |
| unique() | 고유한 값의 개수를 조회 |
| count() | 결측치 제외한 원소 개수 |
| min(), max(), sum() | 기술통계값 조회, 결측치 있을 경우 빼고 계산 최소값, 최대값, 합계 |
| mean(), median(), std() | 평균, 중앙값, 표준편차 |
| var(), mode() | 분산, 최빈값 |
| idxmax(), idxmin() | 최대값의 index, 최소값의 index |
| describe() | 요약 통계량 제공, 수치형: 기술 통계값 / 범주형(문자열): 빈도수 관련 정보 제공 |
| quantile(q=[분위]) | 분위수 계산, q=[분위] 생략 시 0.5(중앙값) |
결측치 Missing Value
결측치 확인
Series/DataFrame객체.isnull() 또는 isna()
Series/DataFrame객체.notnull() 또는 notna()
결측치 처리
dropna()fillna()