Skip to content

Add example with conversion to pandas DataFrame #21

Open

Description

@timvink

The example in the README.md and the documentation all print each row individually.

In practice many users will try to convert the data to a pandas dataframe. Why not include that example in the getting started. We currently use:

import pandas as pd

cursor.execute(query) 
result = cursor.fetchall() 
df = pd.DataFrame(result, columns=[x[0] for x in cursor.description]) 

Activity

  1. drapadubok commented on Nov 10, 2022

    @drapadubok

    Writing it in this issue since it's kinda related, would it make sense to have an actual option to get the result set as pandas dataframe?

    I'm not seeing something important, perhaps, but this code is confusing: https://github.com/databricks/databricks-sql-python/blob/main/src/databricks/sql/client.py#L657
    Why not have an option to return the actual dataframe, why is it converted back and forth?

  2. Triamus commented on Feb 3, 2023

    @Triamus

    I guess the same would be helpful for writes. I was just wondering what the best way of writing a pandas table to Databricks would be.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions