본문 바로가기
프로그래밍/파이썬(Python)

파이썬(Python) Pandas Series

by comflex 2022. 8. 3.
728x90
반응형

Series

Series는 파이썬 Pandas의 자료 구조 중 하나이다.

  • 코드
import pandas as pd
import numpy as np

pd.__version__ #Pandas version 확인

s = pd.Series([0, 1, 2, 3, 4, 5])
print(s)

현재 사용중인 Pandas 의 버전은 version 명령으로 확인 가능하다.
Series를 만든 후 print 명령을 통해 내용을 출력할 수 있다.

  • 출력
0    0
1    1
2    2
3    3
4    4
5    5
dtype: int64

만약 인덱스를 직접 지정하고 싶은 경우 아래 처럼 index를 지정할 수 있다.

  • 코드
import pandas as pd
import numpy as np

pd.__version__ #Pandas version 확인

s = pd.Series([0, 1, 2, 3, 4, 5], index=['a', 'b', 'c','d', 'e', 'f'])
print(s)
  • 출력
a    0
b    1
c    2
d    3
e    4
f    5
dtype: int64

Dictionary를 만들고 그 Dictionary를 통해 Series를 만들 수 있다.

  • 코드
di={'a':1,
      'b':2,
      'c':3,
      'd':4,
      'e':5,
      'f':6}

s = pd.Series(di)
print(s)
  • 출력
a    1
b    2
c    3
d    4
e    5
f    6
dtype: int64

 

2022.12.30 - [프로그래밍/파이썬(Python)] - 파이썬(Python) Pandas Series index

 

파이썬(Python) Pandas Series index

Pandas Series는 색인(index)를 이용해서 각 요소에 접근할 수 있습니다. 색인은 문자열 값이나 정수 값을 사용할 수 있으며, 정수 값을 이용한 색인은 NumPy 배열과 유사합니다. 아래의 코드는 Pandas Seri

com-flex.tistory.com

2022.12.30 - [프로그래밍/파이썬(Python)] - 파이썬(Python) Pandas Series 산술, 논리 연산

 

파이썬(Python) Pandas Series 산술, 논리 연산

Pandas Series는 다양한 연산을 지원합니다. 이들 연산은 요소별로 수행되며, 색인이 같은 요소끼리 연산이 수행됩니다. 이들 연산은 산술 연산, 비교 연산, 논리 연산, 집계 연산 등이 있습니다. 산

com-flex.tistory.com

 

728x90
반응형