✓ 1차원의 labeled array이다.
✓ can holding any data type(integers, strings, floating point numbers, python objects, etc.)
✓ axis label은 index 로 나타낸다.
✓ 기본 구조 >>> s = pd.Series(data,index=index)
✓ s = pd.Series(,name = 'something')
>> 이걸로 object 생성 가능 (s1 = s.rename('another')
으로 해서 다른 object 생성 가능)
✓ data는 1.Python dict 2.ndarray 3.scalar value등으로 이뤄진다.
✓ index가 pass되면, 그에 맞는 value도 pull된다
In[] : dict = {"b":1,"a":0,"c":2}
In[] : pd.Series(dict)
Out[] :
b 1
a 0
c 2
dtype: int64
In[] : pd.Series(dict, index=["b","a","d","c"])
Out[] :
b 1
a 0
d NaN
c 2
dtype: int64
s["a"]
"e" in s
s["f"]
s.get("f")
✓ data의 길이와 index의 개수가 같아야 한다(ex)s = pd.Series(np.random.randn(5), index={["a","b","c","d","e"]}
✓ ndarray와 비슷하게 작동됨
s[0]
s[:3]
s[s > s.median()]
s[[4,3,1]] >>> indexing 부분 더 보기
np.exp(s)
✓ Series가 ndarray-like일때, 1.actual array를 얻으려면
# 1.actual array 얻으려면
s.array
# 2.actual ndarray 얻으려면
s.to_numpy()
pd.Series(5.0, index=["a","b","c","d","e"])
✓ Series와 ndarray의 key difference (Series는 automatically align the data based on label)
Input[]: s[1:] + s[:-1]
Output[]:
a NaN
b -0.565727
c -3.018117
d -2.271265
e NaN
- 참고 자료 및 최종 수정 >>> [2021_12_08]
https://pandas.pydata.org/docs/user_guide/dsintro.html#dsintro