Informatics Practices

Consider following code when conn is the name of established connection to MySQL database.

sql = SELECT * from Sales where zone = "central"; 
df = pandas.read_sql(sql, conn)
df.head()

What will be stored in df ?

Python Pandas

3 Likes

Answer

The DataFrame df includes all the columns where 'zone' equals 'central'.

Explanation

The code executes an SQL query to select all columns (*) from the "Sales" table where the "zone" column equals to "central". It then reads the results of the query into a pandas DataFrame df using pandas.read_sql(). Then, it returns the first five rows of df using df.head().

Answered By

1 Like


Related Questions