I need to merge three datasets so that I can create a custom function that would do the following: Create a function called theme_by_year that takes as input a year (as an integer) and shows the theme ids and theme names (listed in order by theme id) that were in sets that year. The column names must be id and name_themes (to differentiate between the name of a theme and the name of a set) in that order. The index should be reset and go from 0 to n-1. Each theme should only be listed once even if it appeared in more than one set from that year -- duplicate themes should be based on theme id and not name since there are some themes with the same name but with a different id. Hint: It will help if you were to think about merging appropriate DataFrames to help you get this answer. The desired output should look like this: theme_by_year(1960) Output: id name_themes 0 371 Supplemental 1 497 Books 2 513 Classic
SQL
SQL stands for Structured Query Language, is a form of communication that uses queries structured in a specific format to store, manage & retrieve data from a relational database.
Queries
A query is a type of computer programming language that is used to retrieve data from a database. Databases are useful in a variety of ways. They enable the retrieval of records or parts of records, as well as the performance of various calculations prior to displaying the results. A search query is one type of query that many people perform several times per day. A search query is executed every time you use a search engine to find something. When you press the Enter key, the keywords are sent to the search engine, where they are processed by an algorithm that retrieves related results from the search index. Your query's results are displayed on a search engine results page, or SER.
I need to merge three datasets so that I can create a custom function that would do the following:
Create a function called theme_by_year that takes as input a year (as an integer) and shows the theme ids and theme names (listed in order by theme id) that were in sets that year.
The column names must be id and name_themes (to differentiate between the name of a theme and the name of a set) in that order.
The index should be reset and go from 0 to n-1.
Each theme should only be listed once even if it appeared in more than one set from that year -- duplicate themes should be based on theme id and not name since there are some themes with the same name but with a different id.
Hint: It will help if you were to think about merging appropriate DataFrames to help you get this answer.
The desired output should look like this:
theme_by_year(1960)
Output:
id name_themes
0 371 Supplemental
1 497 Books
2 513 Classic
Here's what I tried, but I did not get the desired output:
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 4 images