Instagram is one of the most popular social media platforms in the world, with millions of active users sharing photos, videos, and comments every day.
Retrieve the count of comments made by users who have posted comments (non-null comment_text), grouping the count by each user's username
TEMP to join the 'users' table with the 'comments' table using a LEFT JOIN based on 'users.id' and 'comments.user_id'.TEMP, filter for rows where 'comment_text' is not NULL using the HAVING clause.TEMP, another subquery TEMP2 is formed to select 'TEMP.username' and 'TEMP.comment_text'..drop() method to remove unwanted columns from the 'comments' DataFrame..rename() method to rename the columns in the 'comments' DataFrame using the dictionary..to_csv() method with parameter as index=False to save the cleaned DataFrame as 'comments_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'follows' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'follows' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'follows_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'likes' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'likes' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'likes_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'photo_tags' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'photo_tags' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'photo_tags_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'photos' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'photos' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'photos_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove the 'location' column from the 'tags' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'tags' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'tags_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove the unwanted columns from the 'users' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'users' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'users_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
%load_ext sql command to load the SQL extension in your Jupyter Notebook environment. This extension allows you to run SQL commands directly within your notebook.%sql magic command to specify the connection string for your MySQL database. Replace <user>, <password>, and <db_name> with your actual database credentials and details.Find the 5 oldest users.
%%sql at the beginning of code cells.What day of the week do most users register on? We need to figure out when to schedule an ad campaign.
date_format function to extract the day of the week ('%W') from the 'created_at' column and rename the result as 'day of the week'.%%sql at the beginning of code cells.Retrieve the total number of likes for each photo.
%%sql at the beginning of code cells.Are we overrun with bots and celebrity accounts? Find the percentage of our users who have either never commented on a photo or have commented on photos before.
TEMP, perform a LEFT JOIN between the 'users' table and the 'comments' table based on 'users.id' and 'comments.user_id'.TEMP, count the distinct users and evaluate the presence of NULL values in 'comment_text' using a CASE statement.%Celebrity_count by finding the percentage of users who have never commented (based on the presence of NULL 'comment_text') using the SUM() and COUNT() functions.Number Of Users Who Never Commented by rounding the %Celebrity_count value.%Bot_count by subtracting %Celebrity_count from 100.Number Of Users Who Always Commented by subtracting the rounded Number Of Users Who Never Commented from 100.Hint:In the subquery TEMP, perform a LEFT JOIN between 'users' and 'comments'. In the main query, use 100 * SUM(CASE WHEN TEMP.comment_text IS NULL THEN 1 ELSE 0 END) / COUNT(DISTINCT TEMP.id) for %Celebrity_count. Round the result for 'Number Of Users Who Never Commented'. Calculate %Bot_count by subtracting %Celebrity_count from 100. Derive 'Number Of Users Who Always Commented' by subtracting the rounded 'Number Of Users Who Never Commented' from 100
Are we overrun with bots and celebrity accounts? Find the percentage of our users who have either never commented on a photo or have commented on every photo.
tableA and tableB, each containing a separate calculation related to user behavior metrics.tableA, count the total number of users who have never commented by using a LEFT JOIN between the 'users' table and the 'comments' table where 'comment_text' is NULL. Perform a GROUP BY on 'users.id' and count the distinct users.tableB, count the total number of users who have liked every photo. This involves joining the 'users' table with the 'likes' table based on 'user_id.' Group the data by 'users.id' and filter it using HAVING to include only those users whose count of distinct liked photos matches the total count of photos in the 'photos' table.tableB by 100 and dividing it by the total count of users obtained from the subquery.Identify users who have never commented on a photo, as there is a problem with celebrities.
Identify users who have liked every single photo on the site, as there is a problem with bots.
(SELECT COUNT(*) FROM photos).%%sql at the beginning of code cells.A brand wants to know which hashtags to use in a post. What are the top 5 most commonly used hashtags?
%%sql at the beginning of code cells.Determine the total number of users who have posted at least one time.
%%sql at the beginning of code cells.Determine the total number of posts by users.
Rank users by the number of postings, from highest to lowest.
users.id)%%sql at the beginning of code cells.Our investors want to know how many times the average user posts, which is calculated as the total number of photos divided by the total number of users.
Find the users who have never posted a photo, as we want to target our inactive users with an email campaign.
%%sql at the beginning of code cells.Are we overrun with bots and celebrity accounts? Find the percentage of our users who have either never commented on a photo or have commented on photos before.
TEMP, perform a LEFT JOIN between the 'users' table and the 'comments' table based on 'users.id' and 'comments.user_id'.TEMP, count the distinct users and evaluate the presence of NULL values in 'comment_text' using a CASE statement.%Celebrity_count by finding the percentage of users who have never commented (based on the presence of NULL 'comment_text') using the SUM() and COUNT() functions.Number Of Users Who Never Commented by rounding the %Celebrity_count value.%Bot_count by subtracting %Celebrity_count from 100.Number Of Users Who Always Commented by subtracting the rounded Number Of Users Who Never Commented from 100.Hint:In the subquery TEMP, perform a LEFT JOIN between 'users' and 'comments'. In the main query, use 100 * SUM(CASE WHEN TEMP.comment_text IS NULL THEN 1 ELSE 0 END) / COUNT(DISTINCT TEMP.id) for %Celebrity_count. Round the result for 'Number Of Users Who Never Commented'. Calculate %Bot_count by subtracting %Celebrity_count from 100. Derive 'Number Of Users Who Always Commented' by subtracting the rounded 'Number Of Users Who Never Commented' from 100
Retrieve the count of comments made by users who have posted comments (non-null comment_text), grouping the count by each user's username
TEMP to join the 'users' table with the 'comments' table using a LEFT JOIN based on 'users.id' and 'comments.user_id'.TEMP, filter for rows where 'comment_text' is not NULL using the HAVING clause.TEMP, another subquery TEMP2 is formed to select 'TEMP.username' and 'TEMP.comment_text'.Are we overrun with bots and celebrity accounts? Find the percentage of our users who have either never commented on a photo or have commented on every photo.
tableA and tableB, each containing a separate calculation related to user behavior metrics.tableA, count the total number of users who have never commented by using a LEFT JOIN between the 'users' table and the 'comments' table where 'comment_text' is NULL. Perform a GROUP BY on 'users.id' and count the distinct users.tableB, count the total number of users who have liked every photo. This involves joining the 'users' table with the 'likes' table based on 'user_id.' Group the data by 'users.id' and filter it using HAVING to include only those users whose count of distinct liked photos matches the total count of photos in the 'photos' table.tableB by 100 and dividing it by the total count of users obtained from the subquery.Identify users who have never commented on a photo, as there is a problem with celebrities.
Identify users who have liked every single photo on the site, as there is a problem with bots.
(SELECT COUNT(*) FROM photos).%%sql at the beginning of code cells.A brand wants to know which hashtags to use in a post. What are the top 5 most commonly used hashtags?
%%sql at the beginning of code cells.Determine the total number of users who have posted at least one time.
%%sql at the beginning of code cells.Determine the total number of posts by users.
Rank users by the number of postings, from highest to lowest.
users.id)%%sql at the beginning of code cells.Our investors want to know how many times the average user posts, which is calculated as the total number of photos divided by the total number of users.
Find the users who have never posted a photo, as we want to target our inactive users with an email campaign.
%%sql at the beginning of code cells.Retrieve the total number of likes for each photo.
%%sql at the beginning of code cells..drop() method to remove unwanted columns from the 'comments' DataFrame..rename() method to rename the columns in the 'comments' DataFrame using the dictionary..to_csv() method with parameter as index=False to save the cleaned DataFrame as 'comments_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'follows' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'follows' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'follows_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'likes' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'likes' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'likes_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'photo_tags' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'photo_tags' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'photo_tags_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'photos' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'photos' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'photos_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove the 'location' column from the 'tags' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'tags' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'tags_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove the unwanted columns from the 'users' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'users' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'users_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
%load_ext sql command to load the SQL extension in your Jupyter Notebook environment. This extension allows you to run SQL commands directly within your notebook.%sql magic command to specify the connection string for your MySQL database. Replace <user>, <password>, and <db_name> with your actual database credentials and details.Find the 5 oldest users.
%%sql at the beginning of code cells.What day of the week do most users register on? We need to figure out when to schedule an ad campaign.
date_format function to extract the day of the week ('%W') from the 'created_at' column and rename the result as 'day of the week'.%%sql at the beginning of code cells..drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'likes' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'likes' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'likes_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'photo_tags' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'photo_tags' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'photo_tags_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'photos' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'photos' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'photos_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove the 'location' column from the 'tags' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'tags' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'tags_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove the unwanted columns from the 'users' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'users' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'users_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
%load_ext sql command to load the SQL extension in your Jupyter Notebook environment. This extension allows you to run SQL commands directly within your notebook.%sql magic command to specify the connection string for your MySQL database. Replace <user>, <password>, and <db_name> with your actual database credentials and details.Find the 5 oldest users.
%%sql at the beginning of code cells.What day of the week do most users register on? We need to figure out when to schedule an ad campaign.
date_format function to extract the day of the week ('%W') from the 'created_at' column and rename the result as 'day of the week'.%%sql at the beginning of code cells.Find the users who have never posted a photo, as we want to target our inactive users with an email campaign.
%%sql at the beginning of code cells.Retrieve the total number of likes for each photo.
%%sql at the beginning of code cells.Our investors want to know how many times the average user posts, which is calculated as the total number of photos divided by the total number of users.
Rank users by the number of postings, from highest to lowest.
users.id)%%sql at the beginning of code cells.Determine the total number of posts by users.
Determine the total number of users who have posted at least one time.
%%sql at the beginning of code cells.A brand wants to know which hashtags to use in a post. What are the top 5 most commonly used hashtags?
%%sql at the beginning of code cells.Identify users who have liked every single photo on the site, as there is a problem with bots.
(SELECT COUNT(*) FROM photos).%%sql at the beginning of code cells.Identify users who have never commented on a photo, as there is a problem with celebrities.
Are we overrun with bots and celebrity accounts? Find the percentage of our users who have either never commented on a photo or have commented on every photo.
tableA and tableB, each containing a separate calculation related to user behavior metrics.tableA, count the total number of users who have never commented by using a LEFT JOIN between the 'users' table and the 'comments' table where 'comment_text' is NULL. Perform a GROUP BY on 'users.id' and count the distinct users.tableB, count the total number of users who have liked every photo. This involves joining the 'users' table with the 'likes' table based on 'user_id.' Group the data by 'users.id' and filter it using HAVING to include only those users whose count of distinct liked photos matches the total count of photos in the 'photos' table.tableB by 100 and dividing it by the total count of users obtained from the subquery.Retrieve the count of comments made by users who have posted comments (non-null comment_text), grouping the count by each user's username
TEMP to join the 'users' table with the 'comments' table using a LEFT JOIN based on 'users.id' and 'comments.user_id'.TEMP, filter for rows where 'comment_text' is not NULL using the HAVING clause.TEMP, another subquery TEMP2 is formed to select 'TEMP.username' and 'TEMP.comment_text'.Are we overrun with bots and celebrity accounts? Find the percentage of our users who have either never commented on a photo or have commented on photos before.
TEMP, perform a LEFT JOIN between the 'users' table and the 'comments' table based on 'users.id' and 'comments.user_id'.TEMP, count the distinct users and evaluate the presence of NULL values in 'comment_text' using a CASE statement.%Celebrity_count by finding the percentage of users who have never commented (based on the presence of NULL 'comment_text') using the SUM() and COUNT() functions.Number Of Users Who Never Commented by rounding the %Celebrity_count value.%Bot_count by subtracting %Celebrity_count from 100.Number Of Users Who Always Commented by subtracting the rounded Number Of Users Who Never Commented from 100.Hint:In the subquery TEMP, perform a LEFT JOIN between 'users' and 'comments'. In the main query, use 100 * SUM(CASE WHEN TEMP.comment_text IS NULL THEN 1 ELSE 0 END) / COUNT(DISTINCT TEMP.id) for %Celebrity_count. Round the result for 'Number Of Users Who Never Commented'. Calculate %Bot_count by subtracting %Celebrity_count from 100. Derive 'Number Of Users Who Always Commented' by subtracting the rounded 'Number Of Users Who Never Commented' from 100
.drop() method to remove unwanted columns from the 'comments' DataFrame..rename() method to rename the columns in the 'comments' DataFrame using the dictionary..to_csv() method with parameter as index=False to save the cleaned DataFrame as 'comments_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'follows' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'follows' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'follows_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove the 'location' column from the 'tags' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'tags' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'tags_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method to remove unwanted columns from the 'comments' DataFrame..rename() method to rename the columns in the 'comments' DataFrame using the dictionary..to_csv() method with parameter as index=False to save the cleaned DataFrame as 'comments_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'follows' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'follows' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'follows_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'likes' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'likes' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'likes_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'photo_tags' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'photo_tags' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'photo_tags_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'photos' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'photos' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'photos_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove the unwanted columns from the 'users' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'users' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'users_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
%load_ext sql command to load the SQL extension in your Jupyter Notebook environment. This extension allows you to run SQL commands directly within your notebook.%sql magic command to specify the connection string for your MySQL database. Replace <user>, <password>, and <db_name> with your actual database credentials and details.Find the 5 oldest users.
%%sql at the beginning of code cells.What day of the week do most users register on? We need to figure out when to schedule an ad campaign.
date_format function to extract the day of the week ('%W') from the 'created_at' column and rename the result as 'day of the week'.%%sql at the beginning of code cells.Find the users who have never posted a photo, as we want to target our inactive users with an email campaign.
%%sql at the beginning of code cells.Our investors want to know how many times the average user posts, which is calculated as the total number of photos divided by the total number of users.
Retrieve the total number of likes for each photo.
%%sql at the beginning of code cells.Are we overrun with bots and celebrity accounts? Find the percentage of our users who have either never commented on a photo or have commented on photos before.
TEMP, perform a LEFT JOIN between the 'users' table and the 'comments' table based on 'users.id' and 'comments.user_id'.TEMP, count the distinct users and evaluate the presence of NULL values in 'comment_text' using a CASE statement.%Celebrity_count by finding the percentage of users who have never commented (based on the presence of NULL 'comment_text') using the SUM() and COUNT() functions.Number Of Users Who Never Commented by rounding the %Celebrity_count value.%Bot_count by subtracting %Celebrity_count from 100.Number Of Users Who Always Commented by subtracting the rounded Number Of Users Who Never Commented from 100.Hint:In the subquery TEMP, perform a LEFT JOIN between 'users' and 'comments'. In the main query, use 100 * SUM(CASE WHEN TEMP.comment_text IS NULL THEN 1 ELSE 0 END) / COUNT(DISTINCT TEMP.id) for %Celebrity_count. Round the result for 'Number Of Users Who Never Commented'. Calculate %Bot_count by subtracting %Celebrity_count from 100. Derive 'Number Of Users Who Always Commented' by subtracting the rounded 'Number Of Users Who Never Commented' from 100
Retrieve the count of comments made by users who have posted comments (non-null comment_text), grouping the count by each user's username
TEMP to join the 'users' table with the 'comments' table using a LEFT JOIN based on 'users.id' and 'comments.user_id'.TEMP, filter for rows where 'comment_text' is not NULL using the HAVING clause.TEMP, another subquery TEMP2 is formed to select 'TEMP.username' and 'TEMP.comment_text'.Are we overrun with bots and celebrity accounts? Find the percentage of our users who have either never commented on a photo or have commented on every photo.
tableA and tableB, each containing a separate calculation related to user behavior metrics.tableA, count the total number of users who have never commented by using a LEFT JOIN between the 'users' table and the 'comments' table where 'comment_text' is NULL. Perform a GROUP BY on 'users.id' and count the distinct users.tableB, count the total number of users who have liked every photo. This involves joining the 'users' table with the 'likes' table based on 'user_id.' Group the data by 'users.id' and filter it using HAVING to include only those users whose count of distinct liked photos matches the total count of photos in the 'photos' table.tableB by 100 and dividing it by the total count of users obtained from the subquery.Identify users who have never commented on a photo, as there is a problem with celebrities.
Identify users who have liked every single photo on the site, as there is a problem with bots.
(SELECT COUNT(*) FROM photos).%%sql at the beginning of code cells.A brand wants to know which hashtags to use in a post. What are the top 5 most commonly used hashtags?
%%sql at the beginning of code cells.Determine the total number of users who have posted at least one time.
%%sql at the beginning of code cells.Determine the total number of posts by users.
Rank users by the number of postings, from highest to lowest.
users.id)%%sql at the beginning of code cells.Find the users who have never posted a photo, as we want to target our inactive users with an email campaign.
%%sql at the beginning of code cells.Retrieve the total number of likes for each photo.
%%sql at the beginning of code cells.Our investors want to know how many times the average user posts, which is calculated as the total number of photos divided by the total number of users.
Rank users by the number of postings, from highest to lowest.
users.id)%%sql at the beginning of code cells.Determine the total number of posts by users.
Determine the total number of users who have posted at least one time.
%%sql at the beginning of code cells.A brand wants to know which hashtags to use in a post. What are the top 5 most commonly used hashtags?
%%sql at the beginning of code cells.Identify users who have liked every single photo on the site, as there is a problem with bots.
(SELECT COUNT(*) FROM photos).%%sql at the beginning of code cells.Identify users who have never commented on a photo, as there is a problem with celebrities.
Are we overrun with bots and celebrity accounts? Find the percentage of our users who have either never commented on a photo or have commented on every photo.
tableA and tableB, each containing a separate calculation related to user behavior metrics.tableA, count the total number of users who have never commented by using a LEFT JOIN between the 'users' table and the 'comments' table where 'comment_text' is NULL. Perform a GROUP BY on 'users.id' and count the distinct users.tableB, count the total number of users who have liked every photo. This involves joining the 'users' table with the 'likes' table based on 'user_id.' Group the data by 'users.id' and filter it using HAVING to include only those users whose count of distinct liked photos matches the total count of photos in the 'photos' table.tableB by 100 and dividing it by the total count of users obtained from the subquery.Retrieve the count of comments made by users who have posted comments (non-null comment_text), grouping the count by each user's username
TEMP to join the 'users' table with the 'comments' table using a LEFT JOIN based on 'users.id' and 'comments.user_id'.TEMP, filter for rows where 'comment_text' is not NULL using the HAVING clause.TEMP, another subquery TEMP2 is formed to select 'TEMP.username' and 'TEMP.comment_text'.Are we overrun with bots and celebrity accounts? Find the percentage of our users who have either never commented on a photo or have commented on photos before.
TEMP, perform a LEFT JOIN between the 'users' table and the 'comments' table based on 'users.id' and 'comments.user_id'.TEMP, count the distinct users and evaluate the presence of NULL values in 'comment_text' using a CASE statement.%Celebrity_count by finding the percentage of users who have never commented (based on the presence of NULL 'comment_text') using the SUM() and COUNT() functions.Number Of Users Who Never Commented by rounding the %Celebrity_count value.%Bot_count by subtracting %Celebrity_count from 100.Number Of Users Who Always Commented by subtracting the rounded Number Of Users Who Never Commented from 100.Hint:In the subquery TEMP, perform a LEFT JOIN between 'users' and 'comments'. In the main query, use 100 * SUM(CASE WHEN TEMP.comment_text IS NULL THEN 1 ELSE 0 END) / COUNT(DISTINCT TEMP.id) for %Celebrity_count. Round the result for 'Number Of Users Who Never Commented'. Calculate %Bot_count by subtracting %Celebrity_count from 100. Derive 'Number Of Users Who Always Commented' by subtracting the rounded 'Number Of Users Who Never Commented' from 100
Find the 5 oldest users.
%%sql at the beginning of code cells.%load_ext sql command to load the SQL extension in your Jupyter Notebook environment. This extension allows you to run SQL commands directly within your notebook.%sql magic command to specify the connection string for your MySQL database. Replace <user>, <password>, and <db_name> with your actual database credentials and details..drop() method with parameters labels=unwanted_columns and axis=1 to remove the unwanted columns from the 'users' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'users' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'users_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove the 'location' column from the 'tags' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'tags' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'tags_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'photos' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'photos' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'photos_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'photo_tags' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'photo_tags' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'photo_tags_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'likes' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'likes' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'likes_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'follows' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'follows' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'follows_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method to remove unwanted columns from the 'comments' DataFrame..rename() method to rename the columns in the 'comments' DataFrame using the dictionary..to_csv() method with parameter as index=False to save the cleaned DataFrame as 'comments_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
What day of the week do most users register on? We need to figure out when to schedule an ad campaign.
date_format function to extract the day of the week ('%W') from the 'created_at' column and rename the result as 'day of the week'.%%sql at the beginning of code cells.What day of the week do most users register on? We need to figure out when to schedule an ad campaign.
date_format function to extract the day of the week ('%W') from the 'created_at' column and rename the result as 'day of the week'.%%sql at the beginning of code cells.Determine the total number of users who have posted at least one time.
%%sql at the beginning of code cells.Find the 5 oldest users.
%%sql at the beginning of code cells.%load_ext sql command to load the SQL extension in your Jupyter Notebook environment. This extension allows you to run SQL commands directly within your notebook.%sql magic command to specify the connection string for your MySQL database. Replace <user>, <password>, and <db_name> with your actual database credentials and details..drop() method with parameters labels=unwanted_columns and axis=1 to remove the unwanted columns from the 'users' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'users' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'users_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove the 'location' column from the 'tags' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'tags' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'tags_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'photos' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'photos' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'photos_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'photo_tags' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'photo_tags' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'photo_tags_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'likes' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'likes' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'likes_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'follows' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'follows' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'follows_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method to remove unwanted columns from the 'comments' DataFrame..rename() method to rename the columns in the 'comments' DataFrame using the dictionary..to_csv() method with parameter as index=False to save the cleaned DataFrame as 'comments_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
Find the users who have never posted a photo, as we want to target our inactive users with an email campaign.
%%sql at the beginning of code cells.Retrieve the total number of likes for each photo.
%%sql at the beginning of code cells.Our investors want to know how many times the average user posts, which is calculated as the total number of photos divided by the total number of users.
Rank users by the number of postings, from highest to lowest.
users.id)%%sql at the beginning of code cells.Determine the total number of posts by users.
A brand wants to know which hashtags to use in a post. What are the top 5 most commonly used hashtags?
%%sql at the beginning of code cells.Identify users who have liked every single photo on the site, as there is a problem with bots.
(SELECT COUNT(*) FROM photos).%%sql at the beginning of code cells.Identify users who have never commented on a photo, as there is a problem with celebrities.
Are we overrun with bots and celebrity accounts? Find the percentage of our users who have either never commented on a photo or have commented on every photo.
tableA and tableB, each containing a separate calculation related to user behavior metrics.tableA, count the total number of users who have never commented by using a LEFT JOIN between the 'users' table and the 'comments' table where 'comment_text' is NULL. Perform a GROUP BY on 'users.id' and count the distinct users.tableB, count the total number of users who have liked every photo. This involves joining the 'users' table with the 'likes' table based on 'user_id.' Group the data by 'users.id' and filter it using HAVING to include only those users whose count of distinct liked photos matches the total count of photos in the 'photos' table.tableB by 100 and dividing it by the total count of users obtained from the subquery.Retrieve the count of comments made by users who have posted comments (non-null comment_text), grouping the count by each user's username
TEMP to join the 'users' table with the 'comments' table using a LEFT JOIN based on 'users.id' and 'comments.user_id'.TEMP, filter for rows where 'comment_text' is not NULL using the HAVING clause.TEMP, another subquery TEMP2 is formed to select 'TEMP.username' and 'TEMP.comment_text'.Are we overrun with bots and celebrity accounts? Find the percentage of our users who have either never commented on a photo or have commented on photos before.
TEMP, perform a LEFT JOIN between the 'users' table and the 'comments' table based on 'users.id' and 'comments.user_id'.TEMP, count the distinct users and evaluate the presence of NULL values in 'comment_text' using a CASE statement.%Celebrity_count by finding the percentage of users who have never commented (based on the presence of NULL 'comment_text') using the SUM() and COUNT() functions.Number Of Users Who Never Commented by rounding the %Celebrity_count value.%Bot_count by subtracting %Celebrity_count from 100.Number Of Users Who Always Commented by subtracting the rounded Number Of Users Who Never Commented from 100.Hint:In the subquery TEMP, perform a LEFT JOIN between 'users' and 'comments'. In the main query, use 100 * SUM(CASE WHEN TEMP.comment_text IS NULL THEN 1 ELSE 0 END) / COUNT(DISTINCT TEMP.id) for %Celebrity_count. Round the result for 'Number Of Users Who Never Commented'. Calculate %Bot_count by subtracting %Celebrity_count from 100. Derive 'Number Of Users Who Always Commented' by subtracting the rounded 'Number Of Users Who Never Commented' from 100
Are we overrun with bots and celebrity accounts? Find the percentage of our users who have either never commented on a photo or have commented on photos before.
TEMP, perform a LEFT JOIN between the 'users' table and the 'comments' table based on 'users.id' and 'comments.user_id'.TEMP, count the distinct users and evaluate the presence of NULL values in 'comment_text' using a CASE statement.%Celebrity_count by finding the percentage of users who have never commented (based on the presence of NULL 'comment_text') using the SUM() and COUNT() functions.Number Of Users Who Never Commented by rounding the %Celebrity_count value.%Bot_count by subtracting %Celebrity_count from 100.Number Of Users Who Always Commented by subtracting the rounded Number Of Users Who Never Commented from 100.Hint:In the subquery TEMP, perform a LEFT JOIN between 'users' and 'comments'. In the main query, use 100 * SUM(CASE WHEN TEMP.comment_text IS NULL THEN 1 ELSE 0 END) / COUNT(DISTINCT TEMP.id) for %Celebrity_count. Round the result for 'Number Of Users Who Never Commented'. Calculate %Bot_count by subtracting %Celebrity_count from 100. Derive 'Number Of Users Who Always Commented' by subtracting the rounded 'Number Of Users Who Never Commented' from 100
Are we overrun with bots and celebrity accounts? Find the percentage of our users who have either never commented on a photo or have commented on every photo.
tableA and tableB, each containing a separate calculation related to user behavior metrics.tableA, count the total number of users who have never commented by using a LEFT JOIN between the 'users' table and the 'comments' table where 'comment_text' is NULL. Perform a GROUP BY on 'users.id' and count the distinct users.tableB, count the total number of users who have liked every photo. This involves joining the 'users' table with the 'likes' table based on 'user_id.' Group the data by 'users.id' and filter it using HAVING to include only those users whose count of distinct liked photos matches the total count of photos in the 'photos' table.tableB by 100 and dividing it by the total count of users obtained from the subquery..drop() method to remove unwanted columns from the 'comments' DataFrame..rename() method to rename the columns in the 'comments' DataFrame using the dictionary..to_csv() method with parameter as index=False to save the cleaned DataFrame as 'comments_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'follows' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'follows' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'follows_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'likes' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'likes' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'likes_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'photo_tags' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'photo_tags' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'photo_tags_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'photos' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'photos' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'photos_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove the 'location' column from the 'tags' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'tags' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'tags_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove the unwanted columns from the 'users' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'users' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'users_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
%load_ext sql command to load the SQL extension in your Jupyter Notebook environment. This extension allows you to run SQL commands directly within your notebook.%sql magic command to specify the connection string for your MySQL database. Replace <user>, <password>, and <db_name> with your actual database credentials and details.Find the 5 oldest users.
%%sql at the beginning of code cells.What day of the week do most users register on? We need to figure out when to schedule an ad campaign.
date_format function to extract the day of the week ('%W') from the 'created_at' column and rename the result as 'day of the week'.%%sql at the beginning of code cells.Retrieve the total number of likes for each photo.
%%sql at the beginning of code cells.Retrieve the count of comments made by users who have posted comments (non-null comment_text), grouping the count by each user's username
TEMP to join the 'users' table with the 'comments' table using a LEFT JOIN based on 'users.id' and 'comments.user_id'.TEMP, filter for rows where 'comment_text' is not NULL using the HAVING clause.TEMP, another subquery TEMP2 is formed to select 'TEMP.username' and 'TEMP.comment_text'.Identify users who have never commented on a photo, as there is a problem with celebrities.
Identify users who have liked every single photo on the site, as there is a problem with bots.
(SELECT COUNT(*) FROM photos).%%sql at the beginning of code cells.A brand wants to know which hashtags to use in a post. What are the top 5 most commonly used hashtags?
%%sql at the beginning of code cells.Determine the total number of users who have posted at least one time.
%%sql at the beginning of code cells.Determine the total number of posts by users.
Rank users by the number of postings, from highest to lowest.
users.id)%%sql at the beginning of code cells.Our investors want to know how many times the average user posts, which is calculated as the total number of photos divided by the total number of users.
Find the users who have never posted a photo, as we want to target our inactive users with an email campaign.
%%sql at the beginning of code cells.Are we overrun with bots and celebrity accounts? Find the percentage of our users who have either never commented on a photo or have commented on photos before.
TEMP, perform a LEFT JOIN between the 'users' table and the 'comments' table based on 'users.id' and 'comments.user_id'.TEMP, count the distinct users and evaluate the presence of NULL values in 'comment_text' using a CASE statement.%Celebrity_count by finding the percentage of users who have never commented (based on the presence of NULL 'comment_text') using the SUM() and COUNT() functions.Number Of Users Who Never Commented by rounding the %Celebrity_count value.%Bot_count by subtracting %Celebrity_count from 100.Number Of Users Who Always Commented by subtracting the rounded Number Of Users Who Never Commented from 100.Hint:In the subquery TEMP, perform a LEFT JOIN between 'users' and 'comments'. In the main query, use 100 * SUM(CASE WHEN TEMP.comment_text IS NULL THEN 1 ELSE 0 END) / COUNT(DISTINCT TEMP.id) for %Celebrity_count. Round the result for 'Number Of Users Who Never Commented'. Calculate %Bot_count by subtracting %Celebrity_count from 100. Derive 'Number Of Users Who Always Commented' by subtracting the rounded 'Number Of Users Who Never Commented' from 100
Retrieve the count of comments made by users who have posted comments (non-null comment_text), grouping the count by each user's username
TEMP to join the 'users' table with the 'comments' table using a LEFT JOIN based on 'users.id' and 'comments.user_id'.TEMP, filter for rows where 'comment_text' is not NULL using the HAVING clause.TEMP, another subquery TEMP2 is formed to select 'TEMP.username' and 'TEMP.comment_text'.Are we overrun with bots and celebrity accounts? Find the percentage of our users who have either never commented on a photo or have commented on every photo.
tableA and tableB, each containing a separate calculation related to user behavior metrics.tableA, count the total number of users who have never commented by using a LEFT JOIN between the 'users' table and the 'comments' table where 'comment_text' is NULL. Perform a GROUP BY on 'users.id' and count the distinct users.tableB, count the total number of users who have liked every photo. This involves joining the 'users' table with the 'likes' table based on 'user_id.' Group the data by 'users.id' and filter it using HAVING to include only those users whose count of distinct liked photos matches the total count of photos in the 'photos' table.tableB by 100 and dividing it by the total count of users obtained from the subquery.Identify users who have never commented on a photo, as there is a problem with celebrities.
Identify users who have liked every single photo on the site, as there is a problem with bots.
(SELECT COUNT(*) FROM photos).%%sql at the beginning of code cells.A brand wants to know which hashtags to use in a post. What are the top 5 most commonly used hashtags?
%%sql at the beginning of code cells.Determine the total number of users who have posted at least one time.
%%sql at the beginning of code cells.Determine the total number of posts by users.
Rank users by the number of postings, from highest to lowest.
users.id)%%sql at the beginning of code cells.Retrieve the total number of likes for each photo.
%%sql at the beginning of code cells.Our investors want to know how many times the average user posts, which is calculated as the total number of photos divided by the total number of users.
.drop() method to remove unwanted columns from the 'comments' DataFrame..rename() method to rename the columns in the 'comments' DataFrame using the dictionary..to_csv() method with parameter as index=False to save the cleaned DataFrame as 'comments_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'follows' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'follows' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'follows_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'likes' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'likes' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'likes_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'photo_tags' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'photo_tags' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'photo_tags_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'photos' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'photos' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'photos_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove the 'location' column from the 'tags' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'tags' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'tags_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove the unwanted columns from the 'users' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'users' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'users_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
%load_ext sql command to load the SQL extension in your Jupyter Notebook environment. This extension allows you to run SQL commands directly within your notebook.%sql magic command to specify the connection string for your MySQL database. Replace <user>, <password>, and <db_name> with your actual database credentials and details.Find the 5 oldest users.
%%sql at the beginning of code cells.What day of the week do most users register on? We need to figure out when to schedule an ad campaign.
date_format function to extract the day of the week ('%W') from the 'created_at' column and rename the result as 'day of the week'.%%sql at the beginning of code cells.Find the users who have never posted a photo, as we want to target our inactive users with an email campaign.
%%sql at the beginning of code cells..drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'photo_tags' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'photo_tags' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'photo_tags_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'photos' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'photos' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'photos_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove the 'location' column from the 'tags' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'tags' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'tags_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove the unwanted columns from the 'users' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'users' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'users_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
%load_ext sql command to load the SQL extension in your Jupyter Notebook environment. This extension allows you to run SQL commands directly within your notebook.%sql magic command to specify the connection string for your MySQL database. Replace <user>, <password>, and <db_name> with your actual database credentials and details.Find the 5 oldest users.
%%sql at the beginning of code cells.What day of the week do most users register on? We need to figure out when to schedule an ad campaign.
date_format function to extract the day of the week ('%W') from the 'created_at' column and rename the result as 'day of the week'.%%sql at the beginning of code cells.Find the users who have never posted a photo, as we want to target our inactive users with an email campaign.
%%sql at the beginning of code cells.Retrieve the total number of likes for each photo.
%%sql at the beginning of code cells.Our investors want to know how many times the average user posts, which is calculated as the total number of photos divided by the total number of users.
Rank users by the number of postings, from highest to lowest.
users.id)%%sql at the beginning of code cells.Determine the total number of posts by users.
Determine the total number of users who have posted at least one time.
%%sql at the beginning of code cells.A brand wants to know which hashtags to use in a post. What are the top 5 most commonly used hashtags?
%%sql at the beginning of code cells.Identify users who have liked every single photo on the site, as there is a problem with bots.
(SELECT COUNT(*) FROM photos).%%sql at the beginning of code cells.Identify users who have never commented on a photo, as there is a problem with celebrities.
Are we overrun with bots and celebrity accounts? Find the percentage of our users who have either never commented on a photo or have commented on every photo.
tableA and tableB, each containing a separate calculation related to user behavior metrics.tableA, count the total number of users who have never commented by using a LEFT JOIN between the 'users' table and the 'comments' table where 'comment_text' is NULL. Perform a GROUP BY on 'users.id' and count the distinct users.tableB, count the total number of users who have liked every photo. This involves joining the 'users' table with the 'likes' table based on 'user_id.' Group the data by 'users.id' and filter it using HAVING to include only those users whose count of distinct liked photos matches the total count of photos in the 'photos' table.tableB by 100 and dividing it by the total count of users obtained from the subquery.Retrieve the count of comments made by users who have posted comments (non-null comment_text), grouping the count by each user's username
TEMP to join the 'users' table with the 'comments' table using a LEFT JOIN based on 'users.id' and 'comments.user_id'.TEMP, filter for rows where 'comment_text' is not NULL using the HAVING clause.TEMP, another subquery TEMP2 is formed to select 'TEMP.username' and 'TEMP.comment_text'.Are we overrun with bots and celebrity accounts? Find the percentage of our users who have either never commented on a photo or have commented on photos before.
TEMP, perform a LEFT JOIN between the 'users' table and the 'comments' table based on 'users.id' and 'comments.user_id'.TEMP, count the distinct users and evaluate the presence of NULL values in 'comment_text' using a CASE statement.%Celebrity_count by finding the percentage of users who have never commented (based on the presence of NULL 'comment_text') using the SUM() and COUNT() functions.Number Of Users Who Never Commented by rounding the %Celebrity_count value.%Bot_count by subtracting %Celebrity_count from 100.Number Of Users Who Always Commented by subtracting the rounded Number Of Users Who Never Commented from 100.Hint:In the subquery TEMP, perform a LEFT JOIN between 'users' and 'comments'. In the main query, use 100 * SUM(CASE WHEN TEMP.comment_text IS NULL THEN 1 ELSE 0 END) / COUNT(DISTINCT TEMP.id) for %Celebrity_count. Round the result for 'Number Of Users Who Never Commented'. Calculate %Bot_count by subtracting %Celebrity_count from 100. Derive 'Number Of Users Who Always Commented' by subtracting the rounded 'Number Of Users Who Never Commented' from 100
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'follows' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'follows' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'follows_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method to remove unwanted columns from the 'comments' DataFrame..rename() method to rename the columns in the 'comments' DataFrame using the dictionary..to_csv() method with parameter as index=False to save the cleaned DataFrame as 'comments_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'likes' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'likes' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'likes_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
%load_ext sql command to load the SQL extension in your Jupyter Notebook environment. This extension allows you to run SQL commands directly within your notebook.%sql magic command to specify the connection string for your MySQL database. Replace <user>, <password>, and <db_name> with your actual database credentials and details..drop() method to remove unwanted columns from the 'comments' DataFrame..rename() method to rename the columns in the 'comments' DataFrame using the dictionary..to_csv() method with parameter as index=False to save the cleaned DataFrame as 'comments_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'follows' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'follows' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'follows_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'likes' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'likes' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'likes_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'photo_tags' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'photo_tags' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'photo_tags_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'photos' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'photos' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'photos_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove the 'location' column from the 'tags' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'tags' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'tags_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove the unwanted columns from the 'users' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'users' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'users_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
Find the 5 oldest users.
%%sql at the beginning of code cells.What day of the week do most users register on? We need to figure out when to schedule an ad campaign.
date_format function to extract the day of the week ('%W') from the 'created_at' column and rename the result as 'day of the week'.%%sql at the beginning of code cells.Find the users who have never posted a photo, as we want to target our inactive users with an email campaign.
%%sql at the beginning of code cells.Our investors want to know how many times the average user posts, which is calculated as the total number of photos divided by the total number of users.
Are we overrun with bots and celebrity accounts? Find the percentage of our users who have either never commented on a photo or have commented on photos before.
TEMP, perform a LEFT JOIN between the 'users' table and the 'comments' table based on 'users.id' and 'comments.user_id'.TEMP, count the distinct users and evaluate the presence of NULL values in 'comment_text' using a CASE statement.%Celebrity_count by finding the percentage of users who have never commented (based on the presence of NULL 'comment_text') using the SUM() and COUNT() functions.Number Of Users Who Never Commented by rounding the %Celebrity_count value.%Bot_count by subtracting %Celebrity_count from 100.Number Of Users Who Always Commented by subtracting the rounded Number Of Users Who Never Commented from 100.Hint:In the subquery TEMP, perform a LEFT JOIN between 'users' and 'comments'. In the main query, use 100 * SUM(CASE WHEN TEMP.comment_text IS NULL THEN 1 ELSE 0 END) / COUNT(DISTINCT TEMP.id) for %Celebrity_count. Round the result for 'Number Of Users Who Never Commented'. Calculate %Bot_count by subtracting %Celebrity_count from 100. Derive 'Number Of Users Who Always Commented' by subtracting the rounded 'Number Of Users Who Never Commented' from 100
Retrieve the count of comments made by users who have posted comments (non-null comment_text), grouping the count by each user's username
TEMP to join the 'users' table with the 'comments' table using a LEFT JOIN based on 'users.id' and 'comments.user_id'.TEMP, filter for rows where 'comment_text' is not NULL using the HAVING clause.TEMP, another subquery TEMP2 is formed to select 'TEMP.username' and 'TEMP.comment_text'.Are we overrun with bots and celebrity accounts? Find the percentage of our users who have either never commented on a photo or have commented on every photo.
tableA and tableB, each containing a separate calculation related to user behavior metrics.tableA, count the total number of users who have never commented by using a LEFT JOIN between the 'users' table and the 'comments' table where 'comment_text' is NULL. Perform a GROUP BY on 'users.id' and count the distinct users.tableB, count the total number of users who have liked every photo. This involves joining the 'users' table with the 'likes' table based on 'user_id.' Group the data by 'users.id' and filter it using HAVING to include only those users whose count of distinct liked photos matches the total count of photos in the 'photos' table.tableB by 100 and dividing it by the total count of users obtained from the subquery.Identify users who have never commented on a photo, as there is a problem with celebrities.
Identify users who have liked every single photo on the site, as there is a problem with bots.
(SELECT COUNT(*) FROM photos).%%sql at the beginning of code cells.A brand wants to know which hashtags to use in a post. What are the top 5 most commonly used hashtags?
%%sql at the beginning of code cells.Determine the total number of users who have posted at least one time.
%%sql at the beginning of code cells.Determine the total number of posts by users.
Rank users by the number of postings, from highest to lowest.
users.id)%%sql at the beginning of code cells.Retrieve the total number of likes for each photo.
%%sql at the beginning of code cells.Are we overrun with bots and celebrity accounts? Find the percentage of our users who have either never commented on a photo or have commented on photos before.
TEMP, perform a LEFT JOIN between the 'users' table and the 'comments' table based on 'users.id' and 'comments.user_id'.TEMP, count the distinct users and evaluate the presence of NULL values in 'comment_text' using a CASE statement.%Celebrity_count by finding the percentage of users who have never commented (based on the presence of NULL 'comment_text') using the SUM() and COUNT() functions.Number Of Users Who Never Commented by rounding the %Celebrity_count value.%Bot_count by subtracting %Celebrity_count from 100.Number Of Users Who Always Commented by subtracting the rounded Number Of Users Who Never Commented from 100.Hint:In the subquery TEMP, perform a LEFT JOIN between 'users' and 'comments'. In the main query, use 100 * SUM(CASE WHEN TEMP.comment_text IS NULL THEN 1 ELSE 0 END) / COUNT(DISTINCT TEMP.id) for %Celebrity_count. Round the result for 'Number Of Users Who Never Commented'. Calculate %Bot_count by subtracting %Celebrity_count from 100. Derive 'Number Of Users Who Always Commented' by subtracting the rounded 'Number Of Users Who Never Commented' from 100
Retrieve the count of comments made by users who have posted comments (non-null comment_text), grouping the count by each user's username
TEMP to join the 'users' table with the 'comments' table using a LEFT JOIN based on 'users.id' and 'comments.user_id'.TEMP, filter for rows where 'comment_text' is not NULL using the HAVING clause.TEMP, another subquery TEMP2 is formed to select 'TEMP.username' and 'TEMP.comment_text'.Are we overrun with bots and celebrity accounts? Find the percentage of our users who have either never commented on a photo or have commented on every photo.
tableA and tableB, each containing a separate calculation related to user behavior metrics.tableA, count the total number of users who have never commented by using a LEFT JOIN between the 'users' table and the 'comments' table where 'comment_text' is NULL. Perform a GROUP BY on 'users.id' and count the distinct users.tableB, count the total number of users who have liked every photo. This involves joining the 'users' table with the 'likes' table based on 'user_id.' Group the data by 'users.id' and filter it using HAVING to include only those users whose count of distinct liked photos matches the total count of photos in the 'photos' table.tableB by 100 and dividing it by the total count of users obtained from the subquery.Identify users who have never commented on a photo, as there is a problem with celebrities.
Identify users who have liked every single photo on the site, as there is a problem with bots.
(SELECT COUNT(*) FROM photos).%%sql at the beginning of code cells.A brand wants to know which hashtags to use in a post. What are the top 5 most commonly used hashtags?
%%sql at the beginning of code cells.Determine the total number of users who have posted at least one time.
%%sql at the beginning of code cells.Determine the total number of posts by users.
Rank users by the number of postings, from highest to lowest.
users.id)%%sql at the beginning of code cells.Retrieve the total number of likes for each photo.
%%sql at the beginning of code cells.Our investors want to know how many times the average user posts, which is calculated as the total number of photos divided by the total number of users.
.drop() method to remove unwanted columns from the 'comments' DataFrame..rename() method to rename the columns in the 'comments' DataFrame using the dictionary..to_csv() method with parameter as index=False to save the cleaned DataFrame as 'comments_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'follows' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'follows' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'follows_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'likes' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'likes' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'likes_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'photo_tags' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'photo_tags' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'photo_tags_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'photos' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'photos' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'photos_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove the unwanted columns from the 'users' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'users' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'users_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
%load_ext sql command to load the SQL extension in your Jupyter Notebook environment. This extension allows you to run SQL commands directly within your notebook.%sql magic command to specify the connection string for your MySQL database. Replace <user>, <password>, and <db_name> with your actual database credentials and details.Find the 5 oldest users.
%%sql at the beginning of code cells.What day of the week do most users register on? We need to figure out when to schedule an ad campaign.
date_format function to extract the day of the week ('%W') from the 'created_at' column and rename the result as 'day of the week'.%%sql at the beginning of code cells.Find the users who have never posted a photo, as we want to target our inactive users with an email campaign.
%%sql at the beginning of code cells..drop() method with parameters labels=unwanted_columns and axis=1 to remove the 'location' column from the 'tags' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'tags' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'tags_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
Find the users who have never posted a photo, as we want to target our inactive users with an email campaign.
%%sql at the beginning of code cells.What day of the week do most users register on? We need to figure out when to schedule an ad campaign.
date_format function to extract the day of the week ('%W') from the 'created_at' column and rename the result as 'day of the week'.%%sql at the beginning of code cells.Find the 5 oldest users.
%%sql at the beginning of code cells.%load_ext sql command to load the SQL extension in your Jupyter Notebook environment. This extension allows you to run SQL commands directly within your notebook.%sql magic command to specify the connection string for your MySQL database. Replace <user>, <password>, and <db_name> with your actual database credentials and details..drop() method with parameters labels=unwanted_columns and axis=1 to remove the unwanted columns from the 'users' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'users' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'users_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove the 'location' column from the 'tags' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'tags' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'tags_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'photos' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'photos' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'photos_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'photo_tags' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'photo_tags' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'photo_tags_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'likes' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'likes' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'likes_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'follows' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'follows' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'follows_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method to remove unwanted columns from the 'comments' DataFrame..rename() method to rename the columns in the 'comments' DataFrame using the dictionary..to_csv() method with parameter as index=False to save the cleaned DataFrame as 'comments_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
Retrieve the total number of likes for each photo.
%%sql at the beginning of code cells.Our investors want to know how many times the average user posts, which is calculated as the total number of photos divided by the total number of users.
Rank users by the number of postings, from highest to lowest.
users.id)%%sql at the beginning of code cells.Determine the total number of posts by users.
Determine the total number of users who have posted at least one time.
%%sql at the beginning of code cells.A brand wants to know which hashtags to use in a post. What are the top 5 most commonly used hashtags?
%%sql at the beginning of code cells.Identify users who have liked every single photo on the site, as there is a problem with bots.
(SELECT COUNT(*) FROM photos).%%sql at the beginning of code cells.Identify users who have never commented on a photo, as there is a problem with celebrities.
Are we overrun with bots and celebrity accounts? Find the percentage of our users who have either never commented on a photo or have commented on every photo.
tableA and tableB, each containing a separate calculation related to user behavior metrics.tableA, count the total number of users who have never commented by using a LEFT JOIN between the 'users' table and the 'comments' table where 'comment_text' is NULL. Perform a GROUP BY on 'users.id' and count the distinct users.tableB, count the total number of users who have liked every photo. This involves joining the 'users' table with the 'likes' table based on 'user_id.' Group the data by 'users.id' and filter it using HAVING to include only those users whose count of distinct liked photos matches the total count of photos in the 'photos' table.tableB by 100 and dividing it by the total count of users obtained from the subquery.Retrieve the count of comments made by users who have posted comments (non-null comment_text), grouping the count by each user's username
TEMP to join the 'users' table with the 'comments' table using a LEFT JOIN based on 'users.id' and 'comments.user_id'.TEMP, filter for rows where 'comment_text' is not NULL using the HAVING clause.TEMP, another subquery TEMP2 is formed to select 'TEMP.username' and 'TEMP.comment_text'.Are we overrun with bots and celebrity accounts? Find the percentage of our users who have either never commented on a photo or have commented on photos before.
TEMP, perform a LEFT JOIN between the 'users' table and the 'comments' table based on 'users.id' and 'comments.user_id'.TEMP, count the distinct users and evaluate the presence of NULL values in 'comment_text' using a CASE statement.%Celebrity_count by finding the percentage of users who have never commented (based on the presence of NULL 'comment_text') using the SUM() and COUNT() functions.Number Of Users Who Never Commented by rounding the %Celebrity_count value.%Bot_count by subtracting %Celebrity_count from 100.Number Of Users Who Always Commented by subtracting the rounded Number Of Users Who Never Commented from 100.Hint:In the subquery TEMP, perform a LEFT JOIN between 'users' and 'comments'. In the main query, use 100 * SUM(CASE WHEN TEMP.comment_text IS NULL THEN 1 ELSE 0 END) / COUNT(DISTINCT TEMP.id) for %Celebrity_count. Round the result for 'Number Of Users Who Never Commented'. Calculate %Bot_count by subtracting %Celebrity_count from 100. Derive 'Number Of Users Who Always Commented' by subtracting the rounded 'Number Of Users Who Never Commented' from 100
Retrieve the count of comments made by users who have posted comments (non-null comment_text), grouping the count by each user's username
TEMP to join the 'users' table with the 'comments' table using a LEFT JOIN based on 'users.id' and 'comments.user_id'.TEMP, filter for rows where 'comment_text' is not NULL using the HAVING clause.TEMP, another subquery TEMP2 is formed to select 'TEMP.username' and 'TEMP.comment_text'..drop() method to remove unwanted columns from the 'comments' DataFrame..rename() method to rename the columns in the 'comments' DataFrame using the dictionary..to_csv() method with parameter as index=False to save the cleaned DataFrame as 'comments_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'follows' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'follows' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'follows_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'likes' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'likes' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'likes_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'photo_tags' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'photo_tags' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'photo_tags_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'photos' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'photos' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'photos_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove the 'location' column from the 'tags' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'tags' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'tags_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove the unwanted columns from the 'users' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'users' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'users_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
%load_ext sql command to load the SQL extension in your Jupyter Notebook environment. This extension allows you to run SQL commands directly within your notebook.%sql magic command to specify the connection string for your MySQL database. Replace <user>, <password>, and <db_name> with your actual database credentials and details.Find the 5 oldest users.
%%sql at the beginning of code cells.What day of the week do most users register on? We need to figure out when to schedule an ad campaign.
date_format function to extract the day of the week ('%W') from the 'created_at' column and rename the result as 'day of the week'.%%sql at the beginning of code cells.Retrieve the total number of likes for each photo.
%%sql at the beginning of code cells.Our investors want to know how many times the average user posts, which is calculated as the total number of photos divided by the total number of users.
Rank users by the number of postings, from highest to lowest.
users.id)%%sql at the beginning of code cells.Determine the total number of posts by users.
Determine the total number of users who have posted at least one time.
%%sql at the beginning of code cells.A brand wants to know which hashtags to use in a post. What are the top 5 most commonly used hashtags?
%%sql at the beginning of code cells.Identify users who have liked every single photo on the site, as there is a problem with bots.
(SELECT COUNT(*) FROM photos).%%sql at the beginning of code cells.Identify users who have never commented on a photo, as there is a problem with celebrities.
Are we overrun with bots and celebrity accounts? Find the percentage of our users who have either never commented on a photo or have commented on every photo.
tableA and tableB, each containing a separate calculation related to user behavior metrics.tableA, count the total number of users who have never commented by using a LEFT JOIN between the 'users' table and the 'comments' table where 'comment_text' is NULL. Perform a GROUP BY on 'users.id' and count the distinct users.tableB, count the total number of users who have liked every photo. This involves joining the 'users' table with the 'likes' table based on 'user_id.' Group the data by 'users.id' and filter it using HAVING to include only those users whose count of distinct liked photos matches the total count of photos in the 'photos' table.tableB by 100 and dividing it by the total count of users obtained from the subquery.Are we overrun with bots and celebrity accounts? Find the percentage of our users who have either never commented on a photo or have commented on photos before.
TEMP, perform a LEFT JOIN between the 'users' table and the 'comments' table based on 'users.id' and 'comments.user_id'.TEMP, count the distinct users and evaluate the presence of NULL values in 'comment_text' using a CASE statement.%Celebrity_count by finding the percentage of users who have never commented (based on the presence of NULL 'comment_text') using the SUM() and COUNT() functions.Number Of Users Who Never Commented by rounding the %Celebrity_count value.%Bot_count by subtracting %Celebrity_count from 100.Number Of Users Who Always Commented by subtracting the rounded Number Of Users Who Never Commented from 100.Hint:In the subquery TEMP, perform a LEFT JOIN between 'users' and 'comments'. In the main query, use 100 * SUM(CASE WHEN TEMP.comment_text IS NULL THEN 1 ELSE 0 END) / COUNT(DISTINCT TEMP.id) for %Celebrity_count. Round the result for 'Number Of Users Who Never Commented'. Calculate %Bot_count by subtracting %Celebrity_count from 100. Derive 'Number Of Users Who Always Commented' by subtracting the rounded 'Number Of Users Who Never Commented' from 100
Find the users who have never posted a photo, as we want to target our inactive users with an email campaign.
%%sql at the beginning of code cells.Retrieve the total number of likes for each photo.
%%sql at the beginning of code cells.Our investors want to know how many times the average user posts, which is calculated as the total number of photos divided by the total number of users.
Rank users by the number of postings, from highest to lowest.
users.id)%%sql at the beginning of code cells.Determine the total number of posts by users.
Determine the total number of users who have posted at least one time.
%%sql at the beginning of code cells.A brand wants to know which hashtags to use in a post. What are the top 5 most commonly used hashtags?
%%sql at the beginning of code cells.Identify users who have liked every single photo on the site, as there is a problem with bots.
(SELECT COUNT(*) FROM photos).%%sql at the beginning of code cells.Identify users who have never commented on a photo, as there is a problem with celebrities.
Are we overrun with bots and celebrity accounts? Find the percentage of our users who have either never commented on a photo or have commented on every photo.
tableA and tableB, each containing a separate calculation related to user behavior metrics.tableA, count the total number of users who have never commented by using a LEFT JOIN between the 'users' table and the 'comments' table where 'comment_text' is NULL. Perform a GROUP BY on 'users.id' and count the distinct users.tableB, count the total number of users who have liked every photo. This involves joining the 'users' table with the 'likes' table based on 'user_id.' Group the data by 'users.id' and filter it using HAVING to include only those users whose count of distinct liked photos matches the total count of photos in the 'photos' table.tableB by 100 and dividing it by the total count of users obtained from the subquery.Retrieve the count of comments made by users who have posted comments (non-null comment_text), grouping the count by each user's username
TEMP to join the 'users' table with the 'comments' table using a LEFT JOIN based on 'users.id' and 'comments.user_id'.TEMP, filter for rows where 'comment_text' is not NULL using the HAVING clause.TEMP, another subquery TEMP2 is formed to select 'TEMP.username' and 'TEMP.comment_text'.Are we overrun with bots and celebrity accounts? Find the percentage of our users who have either never commented on a photo or have commented on photos before.
TEMP, perform a LEFT JOIN between the 'users' table and the 'comments' table based on 'users.id' and 'comments.user_id'.TEMP, count the distinct users and evaluate the presence of NULL values in 'comment_text' using a CASE statement.%Celebrity_count by finding the percentage of users who have never commented (based on the presence of NULL 'comment_text') using the SUM() and COUNT() functions.Number Of Users Who Never Commented by rounding the %Celebrity_count value.%Bot_count by subtracting %Celebrity_count from 100.Number Of Users Who Always Commented by subtracting the rounded Number Of Users Who Never Commented from 100.Hint:In the subquery TEMP, perform a LEFT JOIN between 'users' and 'comments'. In the main query, use 100 * SUM(CASE WHEN TEMP.comment_text IS NULL THEN 1 ELSE 0 END) / COUNT(DISTINCT TEMP.id) for %Celebrity_count. Round the result for 'Number Of Users Who Never Commented'. Calculate %Bot_count by subtracting %Celebrity_count from 100. Derive 'Number Of Users Who Always Commented' by subtracting the rounded 'Number Of Users Who Never Commented' from 100
What day of the week do most users register on? We need to figure out when to schedule an ad campaign.
date_format function to extract the day of the week ('%W') from the 'created_at' column and rename the result as 'day of the week'.%%sql at the beginning of code cells.Find the 5 oldest users.
%%sql at the beginning of code cells.%load_ext sql command to load the SQL extension in your Jupyter Notebook environment. This extension allows you to run SQL commands directly within your notebook.%sql magic command to specify the connection string for your MySQL database. Replace <user>, <password>, and <db_name> with your actual database credentials and details..drop() method with parameters labels=unwanted_columns and axis=1 to remove the unwanted columns from the 'users' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'users' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'users_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove the 'location' column from the 'tags' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'tags' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'tags_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'photos' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'photos' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'photos_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'photo_tags' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'photo_tags' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'photo_tags_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'likes' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'likes' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'likes_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'follows' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'follows' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'follows_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method to remove unwanted columns from the 'comments' DataFrame..rename() method to rename the columns in the 'comments' DataFrame using the dictionary..to_csv() method with parameter as index=False to save the cleaned DataFrame as 'comments_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
Find the users who have never posted a photo, as we want to target our inactive users with an email campaign.
%%sql at the beginning of code cells.What day of the week do most users register on? We need to figure out when to schedule an ad campaign.
date_format function to extract the day of the week ('%W') from the 'created_at' column and rename the result as 'day of the week'.%%sql at the beginning of code cells.Determine the total number of posts by users.
Find the 5 oldest users.
%%sql at the beginning of code cells.%load_ext sql command to load the SQL extension in your Jupyter Notebook environment. This extension allows you to run SQL commands directly within your notebook.%sql magic command to specify the connection string for your MySQL database. Replace <user>, <password>, and <db_name> with your actual database credentials and details..drop() method with parameters labels=unwanted_columns and axis=1 to remove the unwanted columns from the 'users' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'users' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'users_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove the 'location' column from the 'tags' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'tags' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'tags_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'photos' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'photos' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'photos_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'photo_tags' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'photo_tags' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'photo_tags_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'likes' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'likes' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'likes_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'follows' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'follows' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'follows_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method to remove unwanted columns from the 'comments' DataFrame..rename() method to rename the columns in the 'comments' DataFrame using the dictionary..to_csv() method with parameter as index=False to save the cleaned DataFrame as 'comments_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
Find the users who have never posted a photo, as we want to target our inactive users with an email campaign.
%%sql at the beginning of code cells.Retrieve the total number of likes for each photo.
%%sql at the beginning of code cells.Our investors want to know how many times the average user posts, which is calculated as the total number of photos divided by the total number of users.
Rank users by the number of postings, from highest to lowest.
users.id)%%sql at the beginning of code cells.Determine the total number of users who have posted at least one time.
%%sql at the beginning of code cells.A brand wants to know which hashtags to use in a post. What are the top 5 most commonly used hashtags?
%%sql at the beginning of code cells.Identify users who have liked every single photo on the site, as there is a problem with bots.
(SELECT COUNT(*) FROM photos).%%sql at the beginning of code cells.Identify users who have never commented on a photo, as there is a problem with celebrities.
Are we overrun with bots and celebrity accounts? Find the percentage of our users who have either never commented on a photo or have commented on every photo.
tableA and tableB, each containing a separate calculation related to user behavior metrics.tableA, count the total number of users who have never commented by using a LEFT JOIN between the 'users' table and the 'comments' table where 'comment_text' is NULL. Perform a GROUP BY on 'users.id' and count the distinct users.tableB, count the total number of users who have liked every photo. This involves joining the 'users' table with the 'likes' table based on 'user_id.' Group the data by 'users.id' and filter it using HAVING to include only those users whose count of distinct liked photos matches the total count of photos in the 'photos' table.tableB by 100 and dividing it by the total count of users obtained from the subquery.Retrieve the count of comments made by users who have posted comments (non-null comment_text), grouping the count by each user's username
TEMP to join the 'users' table with the 'comments' table using a LEFT JOIN based on 'users.id' and 'comments.user_id'.TEMP, filter for rows where 'comment_text' is not NULL using the HAVING clause.TEMP, another subquery TEMP2 is formed to select 'TEMP.username' and 'TEMP.comment_text'.Are we overrun with bots and celebrity accounts? Find the percentage of our users who have either never commented on a photo or have commented on photos before.
TEMP, perform a LEFT JOIN between the 'users' table and the 'comments' table based on 'users.id' and 'comments.user_id'.TEMP, count the distinct users and evaluate the presence of NULL values in 'comment_text' using a CASE statement.%Celebrity_count by finding the percentage of users who have never commented (based on the presence of NULL 'comment_text') using the SUM() and COUNT() functions.Number Of Users Who Never Commented by rounding the %Celebrity_count value.%Bot_count by subtracting %Celebrity_count from 100.Number Of Users Who Always Commented by subtracting the rounded Number Of Users Who Never Commented from 100.Hint:In the subquery TEMP, perform a LEFT JOIN between 'users' and 'comments'. In the main query, use 100 * SUM(CASE WHEN TEMP.comment_text IS NULL THEN 1 ELSE 0 END) / COUNT(DISTINCT TEMP.id) for %Celebrity_count. Round the result for 'Number Of Users Who Never Commented'. Calculate %Bot_count by subtracting %Celebrity_count from 100. Derive 'Number Of Users Who Always Commented' by subtracting the rounded 'Number Of Users Who Never Commented' from 100
Are we overrun with bots and celebrity accounts? Find the percentage of our users who have either never commented on a photo or have commented on photos before.
TEMP, perform a LEFT JOIN between the 'users' table and the 'comments' table based on 'users.id' and 'comments.user_id'.TEMP, count the distinct users and evaluate the presence of NULL values in 'comment_text' using a CASE statement.%Celebrity_count by finding the percentage of users who have never commented (based on the presence of NULL 'comment_text') using the SUM() and COUNT() functions.Number Of Users Who Never Commented by rounding the %Celebrity_count value.%Bot_count by subtracting %Celebrity_count from 100.Number Of Users Who Always Commented by subtracting the rounded Number Of Users Who Never Commented from 100.Hint:In the subquery TEMP, perform a LEFT JOIN between 'users' and 'comments'. In the main query, use 100 * SUM(CASE WHEN TEMP.comment_text IS NULL THEN 1 ELSE 0 END) / COUNT(DISTINCT TEMP.id) for %Celebrity_count. Round the result for 'Number Of Users Who Never Commented'. Calculate %Bot_count by subtracting %Celebrity_count from 100. Derive 'Number Of Users Who Always Commented' by subtracting the rounded 'Number Of Users Who Never Commented' from 100
Retrieve the count of comments made by users who have posted comments (non-null comment_text), grouping the count by each user's username
TEMP to join the 'users' table with the 'comments' table using a LEFT JOIN based on 'users.id' and 'comments.user_id'.TEMP, filter for rows where 'comment_text' is not NULL using the HAVING clause.TEMP, another subquery TEMP2 is formed to select 'TEMP.username' and 'TEMP.comment_text'.Are we overrun with bots and celebrity accounts? Find the percentage of our users who have either never commented on a photo or have commented on every photo.
tableA and tableB, each containing a separate calculation related to user behavior metrics.tableA, count the total number of users who have never commented by using a LEFT JOIN between the 'users' table and the 'comments' table where 'comment_text' is NULL. Perform a GROUP BY on 'users.id' and count the distinct users.tableB, count the total number of users who have liked every photo. This involves joining the 'users' table with the 'likes' table based on 'user_id.' Group the data by 'users.id' and filter it using HAVING to include only those users whose count of distinct liked photos matches the total count of photos in the 'photos' table.tableB by 100 and dividing it by the total count of users obtained from the subquery.Identify users who have never commented on a photo, as there is a problem with celebrities.
A brand wants to know which hashtags to use in a post. What are the top 5 most commonly used hashtags?
%%sql at the beginning of code cells..drop() method to remove unwanted columns from the 'comments' DataFrame..rename() method to rename the columns in the 'comments' DataFrame using the dictionary..to_csv() method with parameter as index=False to save the cleaned DataFrame as 'comments_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'follows' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'follows' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'follows_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'likes' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'likes' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'likes_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'photo_tags' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'photo_tags' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'photo_tags_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'photos' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'photos' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'photos_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove the 'location' column from the 'tags' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'tags' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'tags_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove the unwanted columns from the 'users' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'users' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'users_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
%load_ext sql command to load the SQL extension in your Jupyter Notebook environment. This extension allows you to run SQL commands directly within your notebook.%sql magic command to specify the connection string for your MySQL database. Replace <user>, <password>, and <db_name> with your actual database credentials and details.What day of the week do most users register on? We need to figure out when to schedule an ad campaign.
date_format function to extract the day of the week ('%W') from the 'created_at' column and rename the result as 'day of the week'.%%sql at the beginning of code cells.Find the users who have never posted a photo, as we want to target our inactive users with an email campaign.
%%sql at the beginning of code cells.Retrieve the total number of likes for each photo.
%%sql at the beginning of code cells.Our investors want to know how many times the average user posts, which is calculated as the total number of photos divided by the total number of users.
Rank users by the number of postings, from highest to lowest.
users.id)%%sql at the beginning of code cells.Determine the total number of posts by users.
Determine the total number of users who have posted at least one time.
%%sql at the beginning of code cells.Identify users who have liked every single photo on the site, as there is a problem with bots.
(SELECT COUNT(*) FROM photos).%%sql at the beginning of code cells.Find the 5 oldest users.
%%sql at the beginning of code cells.Find the 5 oldest users.
%%sql at the beginning of code cells.What day of the week do most users register on? We need to figure out when to schedule an ad campaign.
date_format function to extract the day of the week ('%W') from the 'created_at' column and rename the result as 'day of the week'.%%sql at the beginning of code cells.Find the users who have never posted a photo, as we want to target our inactive users with an email campaign.
%%sql at the beginning of code cells.Retrieve the total number of likes for each photo.
%%sql at the beginning of code cells.Our investors want to know how many times the average user posts, which is calculated as the total number of photos divided by the total number of users.
Rank users by the number of postings, from highest to lowest.
users.id)%%sql at the beginning of code cells.Determine the total number of posts by users.
Determine the total number of users who have posted at least one time.
%%sql at the beginning of code cells.A brand wants to know which hashtags to use in a post. What are the top 5 most commonly used hashtags?
%%sql at the beginning of code cells.Identify users who have liked every single photo on the site, as there is a problem with bots.
(SELECT COUNT(*) FROM photos).%%sql at the beginning of code cells.Identify users who have never commented on a photo, as there is a problem with celebrities.
Are we overrun with bots and celebrity accounts? Find the percentage of our users who have either never commented on a photo or have commented on every photo.
tableA and tableB, each containing a separate calculation related to user behavior metrics.tableA, count the total number of users who have never commented by using a LEFT JOIN between the 'users' table and the 'comments' table where 'comment_text' is NULL. Perform a GROUP BY on 'users.id' and count the distinct users.tableB, count the total number of users who have liked every photo. This involves joining the 'users' table with the 'likes' table based on 'user_id.' Group the data by 'users.id' and filter it using HAVING to include only those users whose count of distinct liked photos matches the total count of photos in the 'photos' table.tableB by 100 and dividing it by the total count of users obtained from the subquery.Retrieve the count of comments made by users who have posted comments (non-null comment_text), grouping the count by each user's username
TEMP to join the 'users' table with the 'comments' table using a LEFT JOIN based on 'users.id' and 'comments.user_id'.TEMP, filter for rows where 'comment_text' is not NULL using the HAVING clause.TEMP, another subquery TEMP2 is formed to select 'TEMP.username' and 'TEMP.comment_text'.Are we overrun with bots and celebrity accounts? Find the percentage of our users who have either never commented on a photo or have commented on photos before.
TEMP, perform a LEFT JOIN between the 'users' table and the 'comments' table based on 'users.id' and 'comments.user_id'.TEMP, count the distinct users and evaluate the presence of NULL values in 'comment_text' using a CASE statement.%Celebrity_count by finding the percentage of users who have never commented (based on the presence of NULL 'comment_text') using the SUM() and COUNT() functions.Number Of Users Who Never Commented by rounding the %Celebrity_count value.%Bot_count by subtracting %Celebrity_count from 100.Number Of Users Who Always Commented by subtracting the rounded Number Of Users Who Never Commented from 100.Hint:In the subquery TEMP, perform a LEFT JOIN between 'users' and 'comments'. In the main query, use 100 * SUM(CASE WHEN TEMP.comment_text IS NULL THEN 1 ELSE 0 END) / COUNT(DISTINCT TEMP.id) for %Celebrity_count. Round the result for 'Number Of Users Who Never Commented'. Calculate %Bot_count by subtracting %Celebrity_count from 100. Derive 'Number Of Users Who Always Commented' by subtracting the rounded 'Number Of Users Who Never Commented' from 100
.drop() method with parameters labels=unwanted_columns and axis=1 to remove the unwanted columns from the 'users' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'users' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'users_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove the 'location' column from the 'tags' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'tags' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'tags_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'photos' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'photos' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'photos_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'photo_tags' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'photo_tags' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'photo_tags_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'likes' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'likes' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'likes_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'follows' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'follows' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'follows_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method to remove unwanted columns from the 'comments' DataFrame..rename() method to rename the columns in the 'comments' DataFrame using the dictionary..to_csv() method with parameter as index=False to save the cleaned DataFrame as 'comments_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
%load_ext sql command to load the SQL extension in your Jupyter Notebook environment. This extension allows you to run SQL commands directly within your notebook.%sql magic command to specify the connection string for your MySQL database. Replace <user>, <password>, and <db_name> with your actual database credentials and details.What day of the week do most users register on? We need to figure out when to schedule an ad campaign.
date_format function to extract the day of the week ('%W') from the 'created_at' column and rename the result as 'day of the week'.%%sql at the beginning of code cells.Rank users by the number of postings, from highest to lowest.
users.id)%%sql at the beginning of code cells.Find the 5 oldest users.
%%sql at the beginning of code cells.%load_ext sql command to load the SQL extension in your Jupyter Notebook environment. This extension allows you to run SQL commands directly within your notebook.%sql magic command to specify the connection string for your MySQL database. Replace <user>, <password>, and <db_name> with your actual database credentials and details..drop() method with parameters labels=unwanted_columns and axis=1 to remove the unwanted columns from the 'users' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'users' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'users_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove the 'location' column from the 'tags' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'tags' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'tags_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'photos' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'photos' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'photos_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'photo_tags' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'photo_tags' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'photo_tags_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'likes' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'likes' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'likes_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'follows' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'follows' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'follows_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method to remove unwanted columns from the 'comments' DataFrame..rename() method to rename the columns in the 'comments' DataFrame using the dictionary..to_csv() method with parameter as index=False to save the cleaned DataFrame as 'comments_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
Find the users who have never posted a photo, as we want to target our inactive users with an email campaign.
%%sql at the beginning of code cells.Retrieve the total number of likes for each photo.
%%sql at the beginning of code cells.Our investors want to know how many times the average user posts, which is calculated as the total number of photos divided by the total number of users.
Determine the total number of posts by users.
Determine the total number of users who have posted at least one time.
%%sql at the beginning of code cells.A brand wants to know which hashtags to use in a post. What are the top 5 most commonly used hashtags?
%%sql at the beginning of code cells.Identify users who have liked every single photo on the site, as there is a problem with bots.
(SELECT COUNT(*) FROM photos).%%sql at the beginning of code cells.Identify users who have never commented on a photo, as there is a problem with celebrities.
Are we overrun with bots and celebrity accounts? Find the percentage of our users who have either never commented on a photo or have commented on every photo.
tableA and tableB, each containing a separate calculation related to user behavior metrics.tableA, count the total number of users who have never commented by using a LEFT JOIN between the 'users' table and the 'comments' table where 'comment_text' is NULL. Perform a GROUP BY on 'users.id' and count the distinct users.tableB, count the total number of users who have liked every photo. This involves joining the 'users' table with the 'likes' table based on 'user_id.' Group the data by 'users.id' and filter it using HAVING to include only those users whose count of distinct liked photos matches the total count of photos in the 'photos' table.tableB by 100 and dividing it by the total count of users obtained from the subquery.Retrieve the count of comments made by users who have posted comments (non-null comment_text), grouping the count by each user's username
TEMP to join the 'users' table with the 'comments' table using a LEFT JOIN based on 'users.id' and 'comments.user_id'.TEMP, filter for rows where 'comment_text' is not NULL using the HAVING clause.TEMP, another subquery TEMP2 is formed to select 'TEMP.username' and 'TEMP.comment_text'.Are we overrun with bots and celebrity accounts? Find the percentage of our users who have either never commented on a photo or have commented on photos before.
TEMP, perform a LEFT JOIN between the 'users' table and the 'comments' table based on 'users.id' and 'comments.user_id'.TEMP, count the distinct users and evaluate the presence of NULL values in 'comment_text' using a CASE statement.%Celebrity_count by finding the percentage of users who have never commented (based on the presence of NULL 'comment_text') using the SUM() and COUNT() functions.Number Of Users Who Never Commented by rounding the %Celebrity_count value.%Bot_count by subtracting %Celebrity_count from 100.Number Of Users Who Always Commented by subtracting the rounded Number Of Users Who Never Commented from 100.Hint:In the subquery TEMP, perform a LEFT JOIN between 'users' and 'comments'. In the main query, use 100 * SUM(CASE WHEN TEMP.comment_text IS NULL THEN 1 ELSE 0 END) / COUNT(DISTINCT TEMP.id) for %Celebrity_count. Round the result for 'Number Of Users Who Never Commented'. Calculate %Bot_count by subtracting %Celebrity_count from 100. Derive 'Number Of Users Who Always Commented' by subtracting the rounded 'Number Of Users Who Never Commented' from 100
Are we overrun with bots and celebrity accounts? Find the percentage of our users who have either never commented on a photo or have commented on photos before.
TEMP, perform a LEFT JOIN between the 'users' table and the 'comments' table based on 'users.id' and 'comments.user_id'.TEMP, count the distinct users and evaluate the presence of NULL values in 'comment_text' using a CASE statement.%Celebrity_count by finding the percentage of users who have never commented (based on the presence of NULL 'comment_text') using the SUM() and COUNT() functions.Number Of Users Who Never Commented by rounding the %Celebrity_count value.%Bot_count by subtracting %Celebrity_count from 100.Number Of Users Who Always Commented by subtracting the rounded Number Of Users Who Never Commented from 100.Hint:In the subquery TEMP, perform a LEFT JOIN between 'users' and 'comments'. In the main query, use 100 * SUM(CASE WHEN TEMP.comment_text IS NULL THEN 1 ELSE 0 END) / COUNT(DISTINCT TEMP.id) for %Celebrity_count. Round the result for 'Number Of Users Who Never Commented'. Calculate %Bot_count by subtracting %Celebrity_count from 100. Derive 'Number Of Users Who Always Commented' by subtracting the rounded 'Number Of Users Who Never Commented' from 100
Retrieve the count of comments made by users who have posted comments (non-null comment_text), grouping the count by each user's username
TEMP to join the 'users' table with the 'comments' table using a LEFT JOIN based on 'users.id' and 'comments.user_id'.TEMP, filter for rows where 'comment_text' is not NULL using the HAVING clause.TEMP, another subquery TEMP2 is formed to select 'TEMP.username' and 'TEMP.comment_text'.Identify users who have never commented on a photo, as there is a problem with celebrities.
.drop() method to remove unwanted columns from the 'comments' DataFrame..rename() method to rename the columns in the 'comments' DataFrame using the dictionary..to_csv() method with parameter as index=False to save the cleaned DataFrame as 'comments_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'follows' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'follows' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'follows_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'likes' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'likes' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'likes_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'photo_tags' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'photo_tags' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'photo_tags_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'photos' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'photos' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'photos_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove the 'location' column from the 'tags' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'tags' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'tags_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove the unwanted columns from the 'users' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'users' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'users_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
%load_ext sql command to load the SQL extension in your Jupyter Notebook environment. This extension allows you to run SQL commands directly within your notebook.%sql magic command to specify the connection string for your MySQL database. Replace <user>, <password>, and <db_name> with your actual database credentials and details.Find the 5 oldest users.
%%sql at the beginning of code cells.Find the users who have never posted a photo, as we want to target our inactive users with an email campaign.
%%sql at the beginning of code cells.What day of the week do most users register on? We need to figure out when to schedule an ad campaign.
date_format function to extract the day of the week ('%W') from the 'created_at' column and rename the result as 'day of the week'.%%sql at the beginning of code cells.Are we overrun with bots and celebrity accounts? Find the percentage of our users who have either never commented on a photo or have commented on every photo.
tableA and tableB, each containing a separate calculation related to user behavior metrics.tableA, count the total number of users who have never commented by using a LEFT JOIN between the 'users' table and the 'comments' table where 'comment_text' is NULL. Perform a GROUP BY on 'users.id' and count the distinct users.tableB, count the total number of users who have liked every photo. This involves joining the 'users' table with the 'likes' table based on 'user_id.' Group the data by 'users.id' and filter it using HAVING to include only those users whose count of distinct liked photos matches the total count of photos in the 'photos' table.tableB by 100 and dividing it by the total count of users obtained from the subquery.Identify users who have liked every single photo on the site, as there is a problem with bots.
(SELECT COUNT(*) FROM photos).%%sql at the beginning of code cells.A brand wants to know which hashtags to use in a post. What are the top 5 most commonly used hashtags?
%%sql at the beginning of code cells.Determine the total number of users who have posted at least one time.
%%sql at the beginning of code cells.Determine the total number of posts by users.
Rank users by the number of postings, from highest to lowest.
users.id)%%sql at the beginning of code cells.Our investors want to know how many times the average user posts, which is calculated as the total number of photos divided by the total number of users.
Retrieve the total number of likes for each photo.
%%sql at the beginning of code cells.Find the 5 oldest users.
%%sql at the beginning of code cells.What day of the week do most users register on? We need to figure out when to schedule an ad campaign.
date_format function to extract the day of the week ('%W') from the 'created_at' column and rename the result as 'day of the week'.%%sql at the beginning of code cells.Find the users who have never posted a photo, as we want to target our inactive users with an email campaign.
%%sql at the beginning of code cells.Retrieve the total number of likes for each photo.
%%sql at the beginning of code cells.Our investors want to know how many times the average user posts, which is calculated as the total number of photos divided by the total number of users.
Rank users by the number of postings, from highest to lowest.
users.id)%%sql at the beginning of code cells.Determine the total number of posts by users.
Determine the total number of users who have posted at least one time.
%%sql at the beginning of code cells.A brand wants to know which hashtags to use in a post. What are the top 5 most commonly used hashtags?
%%sql at the beginning of code cells.Identify users who have liked every single photo on the site, as there is a problem with bots.
(SELECT COUNT(*) FROM photos).%%sql at the beginning of code cells.Identify users who have never commented on a photo, as there is a problem with celebrities.
Are we overrun with bots and celebrity accounts? Find the percentage of our users who have either never commented on a photo or have commented on every photo.
tableA and tableB, each containing a separate calculation related to user behavior metrics.tableA, count the total number of users who have never commented by using a LEFT JOIN between the 'users' table and the 'comments' table where 'comment_text' is NULL. Perform a GROUP BY on 'users.id' and count the distinct users.tableB, count the total number of users who have liked every photo. This involves joining the 'users' table with the 'likes' table based on 'user_id.' Group the data by 'users.id' and filter it using HAVING to include only those users whose count of distinct liked photos matches the total count of photos in the 'photos' table.tableB by 100 and dividing it by the total count of users obtained from the subquery.Retrieve the count of comments made by users who have posted comments (non-null comment_text), grouping the count by each user's username
TEMP to join the 'users' table with the 'comments' table using a LEFT JOIN based on 'users.id' and 'comments.user_id'.TEMP, filter for rows where 'comment_text' is not NULL using the HAVING clause.TEMP, another subquery TEMP2 is formed to select 'TEMP.username' and 'TEMP.comment_text'.Are we overrun with bots and celebrity accounts? Find the percentage of our users who have either never commented on a photo or have commented on photos before.
TEMP, perform a LEFT JOIN between the 'users' table and the 'comments' table based on 'users.id' and 'comments.user_id'.TEMP, count the distinct users and evaluate the presence of NULL values in 'comment_text' using a CASE statement.%Celebrity_count by finding the percentage of users who have never commented (based on the presence of NULL 'comment_text') using the SUM() and COUNT() functions.Number Of Users Who Never Commented by rounding the %Celebrity_count value.%Bot_count by subtracting %Celebrity_count from 100.Number Of Users Who Always Commented by subtracting the rounded Number Of Users Who Never Commented from 100.Hint:In the subquery TEMP, perform a LEFT JOIN between 'users' and 'comments'. In the main query, use 100 * SUM(CASE WHEN TEMP.comment_text IS NULL THEN 1 ELSE 0 END) / COUNT(DISTINCT TEMP.id) for %Celebrity_count. Round the result for 'Number Of Users Who Never Commented'. Calculate %Bot_count by subtracting %Celebrity_count from 100. Derive 'Number Of Users Who Always Commented' by subtracting the rounded 'Number Of Users Who Never Commented' from 100
.drop() method with parameters labels=unwanted_columns and axis=1 to remove the unwanted columns from the 'users' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'users' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'users_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove the 'location' column from the 'tags' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'tags' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'tags_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'photos' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'photos' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'photos_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'photo_tags' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'photo_tags' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'photo_tags_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'likes' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'likes' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'likes_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'follows' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'follows' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'follows_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method to remove unwanted columns from the 'comments' DataFrame..rename() method to rename the columns in the 'comments' DataFrame using the dictionary..to_csv() method with parameter as index=False to save the cleaned DataFrame as 'comments_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
%load_ext sql command to load the SQL extension in your Jupyter Notebook environment. This extension allows you to run SQL commands directly within your notebook.%sql magic command to specify the connection string for your MySQL database. Replace <user>, <password>, and <db_name> with your actual database credentials and details.Find the users who have never posted a photo, as we want to target our inactive users with an email campaign.
%%sql at the beginning of code cells..drop() method to remove unwanted columns from the 'comments' DataFrame..rename() method to rename the columns in the 'comments' DataFrame using the dictionary..to_csv() method with parameter as index=False to save the cleaned DataFrame as 'comments_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
What day of the week do most users register on? We need to figure out when to schedule an ad campaign.
date_format function to extract the day of the week ('%W') from the 'created_at' column and rename the result as 'day of the week'.%%sql at the beginning of code cells.Find the 5 oldest users.
%%sql at the beginning of code cells.%load_ext sql command to load the SQL extension in your Jupyter Notebook environment. This extension allows you to run SQL commands directly within your notebook.%sql magic command to specify the connection string for your MySQL database. Replace <user>, <password>, and <db_name> with your actual database credentials and details..drop() method with parameters labels=unwanted_columns and axis=1 to remove the unwanted columns from the 'users' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'users' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'users_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove the 'location' column from the 'tags' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'tags' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'tags_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'photos' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'photos' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'photos_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'photo_tags' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'photo_tags' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'photo_tags_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'likes' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'likes' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'likes_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
.drop() method with parameters labels=unwanted_columns and axis=1 to remove unwanted columns from the 'follows' DataFrame..rename() method with parameter columns=new_column_names to rename the columns in the 'follows' DataFrame using the dictionary..to_csv() method with parameter index=False to save the cleaned DataFrame as 'follows_cleaned.csv'.Note: Make sure to comment out the to_csv() function line of code that is responsible for exporting the csv file before running the test case ("Run Test").
Retrieve the total number of likes for each photo.
%%sql at the beginning of code cells.Our investors want to know how many times the average user posts, which is calculated as the total number of photos divided by the total number of users.
Rank users by the number of postings, from highest to lowest.
users.id)%%sql at the beginning of code cells.Determine the total number of posts by users.
Determine the total number of users who have posted at least one time.
%%sql at the beginning of code cells.A brand wants to know which hashtags to use in a post. What are the top 5 most commonly used hashtags?
%%sql at the beginning of code cells.Identify users who have liked every single photo on the site, as there is a problem with bots.
(SELECT COUNT(*) FROM photos).%%sql at the beginning of code cells.Identify users who have never commented on a photo, as there is a problem with celebrities.
Are we overrun with bots and celebrity accounts? Find the percentage of our users who have either never commented on a photo or have commented on every photo.
tableA and tableB, each containing a separate calculation related to user behavior metrics.tableA, count the total number of users who have never commented by using a LEFT JOIN between the 'users' table and the 'comments' table where 'comment_text' is NULL. Perform a GROUP BY on 'users.id' and count the distinct users.tableB, count the total number of users who have liked every photo. This involves joining the 'users' table with the 'likes' table based on 'user_id.' Group the data by 'users.id' and filter it using HAVING to include only those users whose count of distinct liked photos matches the total count of photos in the 'photos' table.tableB by 100 and dividing it by the total count of users obtained from the subquery.Retrieve the count of comments made by users who have posted comments (non-null comment_text), grouping the count by each user's username
TEMP to join the 'users' table with the 'comments' table using a LEFT JOIN based on 'users.id' and 'comments.user_id'.TEMP, filter for rows where 'comment_text' is not NULL using the HAVING clause.TEMP, another subquery TEMP2 is formed to select 'TEMP.username' and 'TEMP.comment_text'.Are we overrun with bots and celebrity accounts? Find the percentage of our users who have either never commented on a photo or have commented on photos before.
TEMP, perform a LEFT JOIN between the 'users' table and the 'comments' table based on 'users.id' and 'comments.user_id'.TEMP, count the distinct users and evaluate the presence of NULL values in 'comment_text' using a CASE statement.%Celebrity_count by finding the percentage of users who have never commented (based on the presence of NULL 'comment_text') using the SUM() and COUNT() functions.Number Of Users Who Never Commented by rounding the %Celebrity_count value.%Bot_count by subtracting %Celebrity_count from 100.Number Of Users Who Always Commented by subtracting the rounded Number Of Users Who Never Commented from 100.Hint:In the subquery TEMP, perform a LEFT JOIN between 'users' and 'comments'. In the main query, use 100 * SUM(CASE WHEN TEMP.comment_text IS NULL THEN 1 ELSE 0 END) / COUNT(DISTINCT TEMP.id) for %Celebrity_count. Round the result for 'Number Of Users Who Never Commented'. Calculate %Bot_count by subtracting %Celebrity_count from 100. Derive 'Number Of Users Who Always Commented' by subtracting the rounded 'Number Of Users Who Never Commented' from 100