Practice / strings dates nulls

Has an Email

easy

The Daily Grind's loyalty program can only email customers who left an address.

contacts

Your task: return the id and email of every contact that has an email (a non-null value).

Assign your answer DataFrame to result. Row order doesn't matter.

contactsinput DataFrame

Schema
columntype
idlong
emailstring
Sample rows
idemail
1a@x.com
2null
3c@x.com
4null
Expected output shape
idemail· 2 rows
Hint

Test for a present value with F.col("email").isNotNull() (never != None — a comparison to null is null, not true). Then select("id", "email").

Lesson refresher

This problem builds on Strings, Dates & Nulls (~8 min). Pop it open in a new tab if you want a quick recap.

Loading editor…
Hit Run to execute your code and see the output here.