Python

Pandas 데이터 타입

Yukart 2022. 2. 16. 09:21
반응형

Pandas에서 제공하는 기본 데이터 타입은 다음과 같습니다.

예제

# 데이터프레임 정보 
df.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 3 entries, 0 to 2
Data columns (total 6 columns):
이름    3 non-null object
통솔    3 non-null int64
무력    3 non-null int64
지력    3 non-null int64
정치    3 non-null int64
매력    3 non-null int64
dtypes: int64(5), object(1)
memory usage: 272.0+ bytes

데이터 타입 변경

  • 데이터 타입을 변경할 때는 astype()을 이용할 수 있다. 문자열을 숫자형으로 변경하는 경우처럼 형변경을 할 수 없는 경우 오류가 발생하기 때문에 예외처리를 위하여 map()이나 apply() 함수를 이용해서 형변경해야 한다.

🔗참조 링크

https://wikidocs.net/75115

https://pandas.pydata.org/docs/reference/api/pandas.Series.html

반응형

'Python' 카테고리의 다른 글

[Python] Selenium 사용법 정리  (0) 2023.09.18
Pandas IO File Format  (0) 2022.03.27
Pandas map, apply 예제  (0) 2022.02.16
Pandas 결측치 예제  (0) 2022.02.16