通过this tutorial关于blaze,但是在本地postgresql数据库中使用iris数据集。在
在使用db.iris.Species.distinct()
时,我似乎没有得到相同的输出(参见Ipython笔记本的第16页)。在
我的连接字符串是postgresql://postgres:postgres@localhost:5432/blaze_test
我的简单Python代码是:
import blaze as bz
db = bz.Data('postgresql://postgres:postgres@localhost:5432/blaze_test')
mySpecies = db.iris_data.species.distinct()
print mySpecies
我在控制台(使用Spyder IDE)得到的只是distinct(_55.iris_data.species)
如何在表格中实际打印不同的物种?在
注意:我知道我在代码中使用小写的“s”来表示“species”部分,否则我只会得到一个错误提示:'Field' object has no attribute 'Species'
打印装置在这里让你有点不舒服。在
__str__
实现(这是Python的print
函数调用的)返回表达式的字符串版本。在__repr__
实现(在解释器中执行一行时调用)触发计算,从而允许您查看计算结果。在如果要将结果推送到具体的数据结构中,如
^{pr2}$pandas.Series
,请执行以下操作:好吧,我想我现在知道了。YouTube视频的其余部分让它更清晰了一些。
我应该做一些类似^{{cd1>}或^{{cd2>}之类的事情,然后^{{cd3>}来完成转换。
欢迎使用其他解决方案/要点。
相关问题 更多 >
编程相关推荐