Path: blob/main/L4assets/DSandMLOpsAssets/HandsOn/Notebooks/DS Db2 data exploration.ipynb
1928 views
Db2 data exploration
This notebook is used to explore the tables use in the hands-on lab to better understand their data and relationships.
Connect to Db2
The connection information is provided for you
Rows per table
You can find the names of the tables by looking at the schema file.
The next cell is provided as an example on how to access the Db2 database.
Note that all thedata is in the schema INSURANCE
Answer the following questions:
Is there at least one driver per household?
Is there more than one policy per household?
Any household without a policy?
Are there more than one policy per household that has the highest start_date?
Are there more than one policy per household that has the highest expiry_date?
Are there policies with more than one claim?
Are there multiple policies per driver?
Is there always a claim_details attached to a claim?
Are there columns with many null values? (Figure out which columns are important)
Is there at least one driver per household?
This is more complex than you may thin at first.
Hints:
left outer join
having
Is there more than one policy per household?
hint:
SELECT... FROM (SELECT...)...
Any household without a policy?
Hints:
SUM(case when...)
LEFT OUTER JOIN
Are there more than one policy per household that have the highest start_date?
Are there more than one policy per household that has the highest expiry_date?
Are there policies with more than one claim?
Hint:
Select FROM (SELECT)
Similar to number of policies per household
Are there multiple policies per driver?
Hint:
Similar to the previous query
Requires INSURANCE_POLICY and INSURANCE_DRIVER
Is there always a claim_details attached to a claim?
Are there columns with many null values? (Figure out which columns are important)
Hint: the easiest way is to use Pandas dataframes
Author
Jacques Roy is a member of the IBM Enablement for Data and AI
Copyright © 2023. This notebook and its source code are released under the terms of the MIT License.