DataFrame을 사용하다 보면 Series type이 리턴될 때가 종종 있다.
DataFrame와 Series의 차이는 뭘까?
DataFrame이 Series의 상위 호환이라고 생각하면 쉽다.
Series는 column의 개수가 1개이다. (쉽게 key-value형태로 사용할 수 있음 serries.to_dict() 하면 됨.)
DataFrame은 column의 개수가 N개가 가능하다.
Series를 DataFrame으로 바꿀땐, Series.to_frame('column_name')으로 변경하면 된다.
series.to_frame('column_name')
참고 사이트:
What is the difference between a pandas Series and a single-column DataFrame?
Why does pandas make a distinction between a Series and a single-column DataFrame? In other words: what is the reason of existence of the Series class? I'm mainly using time series with datetime ...
stackoverflow.com
'What I Do > 프로그래밍' 카테고리의 다른 글
keras에서 layer의 weight를 업데이트하지 않고 고정하기 (0) | 2023.01.26 |
---|---|
grep을 쓰다 보면 매칭된 부분의 위, 아래 몇 줄을 더 보고 싶을 때가 있다. (0) | 2023.01.17 |
ValueError: too many values to unpack (expected 2) request.post(data=params) (0) | 2023.01.17 |
Java script 아마추어 (0) | 2022.11.14 |