lgndrzzz
lgndrzzz

Reputation: 108

Zeppelin: how to read a DataFrame with sql

I have to use python with Zeppelin. I'm very new and I find only materials about pyspark into Zeppelin. I want to import a dataframe with python and then access it through 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)

if I try with:

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

and then access it, i.e. :

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

I get the error: "Table or view not found"

I think the problem is that %sql cannot read variables created with %python, but I'm not sure of that.

Upvotes: 1

Views: 1872

Answers (1)

Saravanan Elumalai
Saravanan Elumalai

Reputation: 328

Try %python.sql interpreter. You have to install pandasql package. Check this link for more info.

Upvotes: 1

Related Questions