Demo entry 6741933

series

   

Submitted by anonymous on May 17, 2018 at 04:45
Language: Python 3. Code size: 417 Bytes.

import pandas as pd

obj = pd.Series([1, 2, 3, 4])
print(obj) # 打印出表的结果
print(obj.values) # 打印值
print(obj.value_counts()) # 打印每个值的统计结果
print(obj.plot)
print(obj.data)
print(obj.index) # 打印索引的结果
print(obj[0]) # 按索引访问数据

obj2 = pd.Series([1, 2, 3, 4], index=['a', 'b', 'c', 'd']) # 重新选择索引值

print(obj2[obj2 > 3]) # 可以用这种方法进行筛选
print(obj2 * 2) # 可以对元素直接访问

obj3 = pd.Series({'a': 1, 'b': 2})
print(obj3)

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).