Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

To select a column from the database table, we first need to make our dataframe accessible in our SQL queries. To do this, we call the df.createOrReplaceTempView method and set the temporary view name to insurance_df.

df.createOrReplaceTempView("insurance_df")

df2 = spark.sql("SELECT AGE, SEX FROM insurance_df")
df2.show()
Source by arctype.com #
 
PREVIOUS NEXT
Tagged: #To #select #column #database #dataframe #accessible #SQL #To #call #method #set #temporary #view
ADD COMMENT
Topic
Name
1+2 =