pandas.Series

pandas.Series(data=None, index=None, dtype=None, name=None, copy=False, fastpath=False)

Parameters

data 存储在Series中的数据。如果data是dict,则保持参数顺序。
index 值必须是可散列的并且与数据具有相同的长度。
允许非唯一索引值。
如果data是dict-like并且index是None,那么数据中的键被用作索引。
如果索引不是None,则使用索引值重新生成索引。
dtype 输出的数据类型
name 赋予Series的名称
copy 是否复制输入数据

Example

  1. import pandas as pd
  2. pd.Series({"site": "google", "age": 18, "color": "red"})
  3. ----------------------------------------------------------
  4. site google
  5. age 18
  6. color red
  7. dtype: object

Example

  1. import pandas as pd
  2. pd.Series([1,2,3], index=["x", "y", "z"], name="num_list", dtype="float64")
  3. ----------------------------------------------------
  4. x 1.0
  5. y 2.0
  6. z 3.0
  7. Name: num_list, dtype: float64