quickest way to to convert list of tuples to a series

前端 未结 4 1599
误落风尘
误落风尘 2021-02-19 12:59

Consider a list of tuples lst

lst = [(\'a\', 10), (\'b\', 20)]

question
What is the quickest way to

4条回答
  •  忘掉有多难
    2021-02-19 13:51

    use pd.Series with a dictionary comprehension

    pd.Series({k: v for k, v in lst})
    
    a    10
    b    20
    dtype: int64
    

提交回复
热议问题