主要分為series 和dataframe兩種
Series:
from pandas import Series
#定義,可以混合定義
x = Series(
['a', True, 1]
)
x = Series(
['a', True, 1],
index=['first', 'second', 'third']
)
#訪問
x[1]
#根據index訪問
x['second']
#不能越界訪問
x[3]
#不能追加單個元素
x.append('2')
#追加一個序列
n = Series(['2'])
x.append(n)
x
#需要使用一個變量來承載變化
x = x.append(n)
'2' in x
#判斷值是否存在
'2' in x.values
#切片
x[1:3]
#定位獲取,這個方法經常用于隨機抽樣
x[[0, 2, 1]]
#根據index刪除
x.drop(0)
x.drop('first')
#根據位置刪除
x.drop(x.index[3])
#根據值刪除
x['2'!=x.values]