[Python] Sowflake Notebooks Error: 'SnowflakeQueryResult' object is not subscriptable

Discussão em 'Python' iniciado por Stack, Maio 19, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to run a .ipynb in Notebooks at Snowflake. It all runs smooth until I try to run some python lines to play with the data retrieved by a query. Can anyone explain why am I getting this error? The code I'm trying to run is the following:

    import seaborn as sns
    import pandas as pd
    import numpy as np
    import matplotlib.pyplot as plt

    SELECT*FROM DB.SCHEMA.TABLE_A

    #This worked
    data = sql_data

    # The error starts when I try to run this:
    quartiles=pd.DataFrame()
    f=data['COLUMN_1'].unique()
    l = pd.qcut( f,q=10,labels=[f'd{n}' for n in range (1,11)])
    quartiles['COLUMN_1']=f
    quartiles['quartil']=l
    quartiles


    The error shows me the following:


    TypeError: 'SnowflakeQueryResult' object is not subscriptable Traceback: File "Cell [cell7]", line 2, in f=data['COLUMN_1'].unique()
    ​

    IMPORTANT: remember that when using Snowflake notebooks there's no need to specify session variables nor the name of an SQL body inside of a notebook block. The way to name the SQL variable is on the interface which I did named the SQL as sql_data.

    Continue reading...

Compartilhe esta Página