0% found this document useful (0 votes)
4 views2 pages

Python DataFrame for Person Addresses

The document describes two database tables, Person and Address, detailing their structure and relationships. It provides a Python solution to merge these tables using pandas, reporting the first name, last name, district, and area for each person, with null values for missing addresses. Additionally, it includes tasks related to creating an AWS EC2 server and implementing a language selector on a web page.

Uploaded by

甲甲
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

Python DataFrame for Person Addresses

The document describes two database tables, Person and Address, detailing their structure and relationships. It provides a Python solution to merge these tables using pandas, reporting the first name, last name, district, and area for each person, with null values for missing addresses. Additionally, it includes tasks related to creating an AWS EC2 server and implementing a language selector on a web page.

Uploaded by

甲甲
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Q1.

Given two tables:

Table: Person
+-------------+---------+
| Column Name | Type |
+-------------+---------+
| personId | int |
| lastName | varchar |
| firstName | varchar |
+-------------+---------+
personId is the primary key (column with unique values) for this table. This table contains information about
the ID of some persons and their first and last names.

Table: Address
+-------------+---------+
| Column Name | Type |
+-------------+---------+
| addressId | int |
| personId | int |
| district | varchar |
| area | varchar |
+-------------+---------+
addressId is the primary key (column with unique values) for this table. Each row of this table contains
information about the district and area of one person with ID = PersonId.

Input:
Person table:
+----------+----------+-----------+
| personId | lastName | firstName |
+----------+----------+-----------+
| 1 | Wang | Allen |
| 2 | Alice | Bob |
+----------+----------+-----------+
Address table:
+-----------+----------+---------------+-----------------+
| addressId | personId | district | area |
+-----------+----------+---------------+-----------------+
| 1 | 2 | Kowloon City | Kowloon |
| 2 | 3 | Fanling | New Territories |
+-----------+----------+---------------+-----------------+

Write a solution in Python to input the data above tables to pandas dataframe and report the first name, last
name, district, and area of each person in the Person table. If the address of a personId is not present in the
Address table, report null instead. Return the result table in any order. The result format is as follow.

Output:
+-----------+----------+---------------+----------+
| firstName | lastName | district | area |
+-----------+----------+---------------+----------+
| Allen | Wang | Null | Null |
| Bob | Alice | Kowloon City | Kowloon |
+-----------+----------+---------------+----------+
Explanation:
There is no address in the address table for the personId = 1 so we return null in their district and
area. addressId = 1 contains information about the address of personId = 2.
Q2. Create a free account in AWS, start an EC2 server and set a start page with a HKU logo and the word
TALIC.

Q3. On a web page that was created in Q2, add a language selector that allows users to choose between
three written languages. Each language option should be represented by a country flag next to the language
name. Here's an example of how the language selector could look:

You might also like