I am trying to read my snowflake query in a pandas dataframe, however I get an "Attribute Error" stating 'SnowflakeCursor' object has no attribute 'shape' (code below)...
Snowflake python connector works. fetch_pandas_all() works. Once I try reading the query as a pandas dataframe, it breaks.
import pyodbc
import sys
import os
import getpass
import snowflake.connector
import pyarrow
conn = snowflake.connector.connect(user=' ', password=' ', account=' ', warehouse=' ', database=' ', schema=' ') cur = conn.cursor() tenure = cur.execute( """SELECT DISTINCT CT_ID, CT_STRT_DATE, MONTHS_BETWEEN(TO_DATE('2022-01-01'), TO_DATE(CT_STRT_DATE)) AS TENURE FROM . .**** WHERE CT_SVC_FREQ != 'OT' AND CT_CNCL_DATE IS NULL AND CT_ID LIKE 'S|%' ORDER BY CT_STRT_DATE DESC""")
print(tenure.fetch_pandas_all()) --- This code works fine
Once I try to manipulate using pandas, I run into errors...
print(tenure.shape) -- breaks w/ "Attribute Error"
What about this way:
df_new = tenure.fetch_pandas_all()
total_rows = df_new.shape[0]
Creating a new DF should allow you to run shape
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.