pandas 为什么 Python ggplot 返回名称“aes”未定义?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23457513/
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 22:00:07 来源:igfitidea点击:
Why Python ggplot returns name 'aes' is not defined?
提问by Hugo
When I use the following comand
当我使用以下命令时
p = ggplot(aes(x='DTM',y='TMP1'), data=data)
I get the following error
我收到以下错误
NameError: name 'aes' is not defined
Could you help me?
你可以帮帮我吗?
回答by Thomas Orozco
You need to import aes:
您需要导入aes:
from ggplot import aes
Alternatively, you can just import everything in the ggplotnamespace (though *imports are usually frowned upon as they make it difficult to track down where a name is coming from):
或者,您可以只导入ggplot命名空间中的所有内容(尽管*导入通常不受欢迎,因为它们很难追踪名称的来源):
from ggplot import *

