问Python如何选取字典中的某些项创建Series实例?

答 1 个回答|432 次阅读
Coco老师 - 官方公众号:青少儿编程学习网
擅长:编程教育网站:https://kidscodes.cn/

仅使用“x”和“y”中的数据创建序列:

import pandas as pd
calories = {"x": 20, "y": 80, "z": 90}
myvar = pd.Series(calories, index = ["x", "y"])
print(myvar)

执行结果:

x    20
y 80
dtype: int64

推荐课程 »更多

    推荐问答

    推荐知识

    Python精选库大全,青少年Python编程学习总结

    Python最适合青少儿进阶学习的编程语言