In [ ]:
!pip install -I numpy==1.19.2
!pip install snowflake-connector-python
import warnings
warnings.filterwarnings("ignore")
!pip install -I pyarrow==5.0.0
In [ ]:
# import basic data science libraries

import pandas as pd
import numpy as np
In [ ]:
import snowflake.connector
import getpass

# using a simpler way to use your login info without embedding it in the notebook 
# other enterprise connection patterns (e.g., SSO) are in the Snowflake docs: https://docs.snowflake.com/en/user-guide/python-connector-example.html
snowflake_username = getpass.getpass("Enter Snowflake Username")
snowflake_pwd = getpass.getpass("Enter Snowflake Password")
snowflake_acct = 'nna57244.us-east-1'

print(snowflake_username)
print(snowflake_acct)
In [ ]:
ctx = snowflake.connector.connect(
  user=snowflake_username,
  password=snowflake_pwd,
  account=snowflake_acct
  )
cs = ctx.cursor()
try:
	cs.execute("SELECT current_version()")
	one_row = cs.fetchone()
	print(one_row[0])

	cs.execute("USE DATABASE PREDICTIVE_MAINTENANCE")    

	query_output = cs.execute( "select top 18 UDI, FAILURE_SCORE from DAILY_SCORED_MACHINES ORDER BY FAILURE_SCORE DESC;" )

	df_snowflake_scored_data = query_output.fetch_pandas_all() 


finally:
    cs.close()



ctx.close()
5.43.1
In [ ]:
df_snowflake_scored_data
Out[ ]:
UDI FAILURE_SCORE
0 4463 0.988231
1 4418 0.985929
2 1017 0.984222
3 4422 0.984187
4 4481 0.983519
5 4511 0.983505
6 8399 0.982481
7 4534 0.982299
8 4406 0.982265
9 4436 0.982169
10 4502 0.982113
11 4449 0.982031
12 4442 0.981653
13 4537 0.981439
14 4410 0.981367
15 4284 0.980647
16 4401 0.979968
17 604 0.979874