Zeppelin:如何使用 sql 读取 DataFrame

Zeppelin: how to read a DataFrame with sql

我必须将 python 与 Zeppelin 一起使用。我很新,我只找到关于 pyspark 的材料到 Zeppelin。 我想用 python 导入数据框,然后通过 sql:

访问它
%python    
import pandas as pd #To work with dataset
import numpy as np #Math library     
#Importing the data
df_credit = pd.read_csv("../data.csv",index_col=0)

如果我尝试:

%python
from sqlalchemy import create_engine
engine = create_engine('sqlite://')
df_credit.to_sql('mydatasql',con=engine)

然后访问它,即:

%sql select Age, count(1) from mydatasql where Age < 30 group by Age order by Age

我收到错误:"Table or view not found"

我认为问题是 %sql 无法读取使用 %python 创建的变量,但我不确定。

尝试 %python.sql 解释器。 您必须安装 pandasql 软件包。 查看此 link 了解更多信息。