시리즈Series는 판다스에서 사용하는 리스트. 리스트와 같은 역할을 함.
컬럼이 하나만 있는 데이터프레임이라고 생각하면 됨.
컬럼명 대신 name을 지정할 수 있고, 각 행의 이름인 인덱스도 지정할 수 있다.
시리즈 만들기
#시리즈 안에 다 집어넣기
pd.Series(['4 cups', '1 cup', '2 large', '1 can'],
index = ['Flour', 'Milk', 'Eggs', 'Spam'], name = 'Dinner')
#리스트를 만들어서 시리즈 안에 넣기: 더 깔끔!
quantities = ['4 cups', '1 cup', '2 large', '1 can']
items = ['Flour', 'Milk', 'Eggs', 'Spam']
pd.Series(quantities, index=items, name='Dinner')
#둘 다 결과는 다음과 같음
Flour 4 cups
Milk 1 cup
Eggs 2 large
Spam 1 can
Name: Dinner, dtype: object
참고
https://www.kaggle.com/code/residentmario/creating-reading-and-writing
Creating, Reading and Writing
Explore and run machine learning code with Kaggle Notebooks | Using data from multiple data sources
www.kaggle.com
'파이썬' 카테고리의 다른 글
[판다스] df.idxmax(): 값이 가장 큰 행의 인덱스 반환 (0) | 2024.01.26 |
---|---|
[판다스] iloc, loc으로 인덱싱 하기 (0) | 2024.01.20 |
[판다스] 데이터프레임을 만드는 다양한 방법과 컬럼명 지정하기 (0) | 2024.01.20 |
[판다스] pandas.set_option error 옛 코드를 돌리다가 오류 났을 때 (0) | 2024.01.20 |
[파이썬] 키워드를 리스트 안에서 검색하기 (0) | 2024.01.17 |