pandas 对象熊猫没有属性名称系列

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30227883/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 23:20:39  来源:igfitidea点击:

Object pandas has no attribute name Series

pythonpandasdata-analysis

提问by Praveen.883

import pandas as pd
numbers = {1,2,3,4,5}
ser = pd.Series(numbers)
print ser

I write this code in python for pandas series. but it's giving this

我用python为pandas系列编写了这段代码。但它给了这个

"AttributeError: 'module' object has no attribute 'Series'"

“AttributeError:‘module’对象没有‘Series’属性”

please help me

请帮我

回答by Praveen.883

The Error in my problem is the file name.

我的问题中的错误是文件名。

I save the file as pandas.py that's why i got the error.

我将文件保存为 pandas.py 这就是我收到错误的原因。

回答by Liam Foley

http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.html

http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.html

data : array-like, dict, or scalar value Contains data stored in Series

data : array-like, dict, or scalar value 包含存储在 Series 中的数据

Don't think a set counts as array-like, so just convert it to a list before calling pd.Series.

不要认为集合算作类似数组,因此只需在调用 pd.Series 之前将其转换为列表即可。

import pandas as pd
numbers = {1,2,3,4,5}
ser = pd.Series(list(numbers))

Output:

输出:

print ser

0    1
1    2
2    3
3    4
4    5

回答by Ajith Kannan

Import pandas as pd

将Pandas导入为 pd

a={1:"Ajith",2:"Kannan"} pd.Series(a)

a={1:"Ajith",2:"Kannan"} pd.Series(a)

Output:

输出:

1 Ajith

1 阿吉斯

2 Kannan

2 坎南

Series is using capital S

系列使用大写 S

回答by Yash Talaiche

change the file name from pandas.py to any name

将文件名从 pandas.py 更改为任意名称