Querying data using dataiku api

antr
antr Registered Posts: 1

I have the following code that works, this is running it outside of the DSS instance

import dataikuapi

import requests

import urllib3

import pandas as pd

# Disable SSL verification warnings (if needed)

urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

# Connect to the Dataiku DSS instance

client = dataikuapi.DSSClient(

"someURL",

api_key="somekye",

requests_session=requests.Session()

)

# Force the requests session to ignore SSL verification (if required)

client._session.verify = False

# Get the project and dataset

project = client.get_project("PROJ_NAME ")

dataset = project.get_dataset("table")

I am able to establish a connection and dataset doesn't fail but now I cannot actually get the data into a dataframe, all the info I found in the internet and documentation says:

dataframe = dataset.get_dataframe()

Which fails and tells me dataset doesn't have that method. So, how do I get the data from the dataset?

Thanks

Answers

  • Alexandru
    Alexandru Dataiker, Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Adv Designer, Registered Posts: 1,345 Dataiker

    Hi,

    To use get_dataframe() you must use a dataset object. If the method doesn't it usually means you are using the dataikuapi dataset object e.g ( using get_dataset(), this is use to change the settings of the dataset but not read data directly)

    One is use dataiku client directly and use

    import dataiku

    dataiku.set_remote_dss("https://dss.example", "YOURAPIKEY", no_check_certificate=True)
    client = dataiku.api_client()

    dataiku.set_default_project_key("ADMDSS")
    dataset = dataiku.Dataset("dataset_name")

    df = dataset.get_dataframe()


    The other is to convert your dataikuapi dataset object core datasets object :
    https://developer.dataiku.com/latest/api-reference/python/datasets.html#dataikuapi.dss.dataset.DSSDataset.get_as_core_dataset

    Kind Regards,

Setup Info
    Tags
      Help me…