[멋쟁이 사자처럼 AIS7][0303]

HI,HYEN·2022년 10월 6일

0303

# 파일이 있는지 없는지 확인할 수 있는 라이브러리
from glob import glob
# 데이터 중복 확인
.duplicated()
# 데이터 중복 제거
.drop_duplicates()

연번 -> 서울시 기준
환자 -> 전국 기준

# A데이터프레임의 연번의 유니크값 수
A['연번'].nunique()
# A데이터프레임의 연번의 유니크값 (시리즈에서만 사용가능)
A['연번].unique()
# 연번을 인덱스 값으로 변경
.set_index('연번')
# 인덱스값 기준으로 정렬, ascending=False(역순 -> 최신부터 보임)
.sort_index(ascending=False)
# 판다스의 attributes
.shape()	# 행열 수
.dtypes	#데이터 타입 확인
.columns	# 컬럼 확인
.index	# 인덱스값 확인
.info()	# 데이터 요약
# 결측치 확인
.isnull()
# 결측치의 합계
.isnull().sum()
# 결측치 비율
.isnull().mean() * 100
# 기술통계 값 (인덱스 값은 안나옴)
.describe()
#문자 데이터에 대한 기술통계 값
# top -> 최빈값, freq -> 최빈값의 빈도수
.describe(include='object')

04 판다스 기초 PPT 참고
[https://pandas.pydata.org/docs/reference/series.html#accessors][https://pandas.pydata.org/docs/reference/series.html#datetimelike-properties]

# 데이터 타입 변경
pd.to_datetime(시리즈)
# 연도 파생변수 만들기
.dt.year
# 문자 데이터로 변환
.astype(str)
astype(str) <= pandas series, str() <= python 문자열
# 데이터 타입 확인
.dtype
# 요소를 변환값으로 변환 (새 리스트 생성)
.map(변환값, 요소)

lambda 변수 : 반환값 -> 익명함수

def  add10(x):
      return x+10

lambda x: x+10
# 로그 없이 보는 법
_ = A.hist()

A.hist());

A.hist()
plt.show()
# 빈도수 구하기
.value_counts()
# 비율 구하기(normalize => 정규화(값을 다 더했을 때 1)
.value_counts(normalize=True) * 100
# rot로 글씨 회전 0,90,180,,,
.plot(kind='bar', rot=0)
# __을 기준으로 선 긋기, 
plt.axhline(__, c=, lw=라인크기, ls=라인형태)
# start부터 end까지 전제 기간 생성
pd.date_range(start=, end=)
# 데이터프레임으로 변환
.to_frame()
#결측치 ()로 채우기
.fillna(0)
# 누적합계 구하기
.cumsum()
profile
Today I Learn

0개의 댓글