From the course: Complete Guide to Databricks for Data Engineering
Unlock this course with a free trial
Join today to access over 24,700 courses taught by industry experts.
Handle date manipulation in PySpark - Databricks Tutorial
From the course: Complete Guide to Databricks for Data Engineering
Handle date manipulation in PySpark
- Let's just use our existing data frame and see if we have any date column inside it or not. So let me do this df.printSchema() You'll find that we have one specific column that is registration date, which is of type date. Now when you have a column, which is of date type, you can do a lot of thing from this date column. Now there are many functions rather than importing all of those functions again and again explicitly and just using pyspark.sql.functions and I'm importing everything. So I will say that import * Now let's say for example, I wanted to get the day from that specific registration date. How I can do that, I will say data frame one is equal to df.select "registration_date", I can get an year out of it using an year function and I'll say year from registration date. Similarly, if I want to get the month, I can just say month and I will say registration date. And if I want to get the day of the month, I would say day of the month like this and let's just display this. Now…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
Use filter and where transformations in PySpark8m 30s
-
(Locked)
Add or remove columns in PySpark8m 56s
-
(Locked)
Use the select function in PySpark6m 16s
-
(Locked)
Use UNION and DISTINCT in PySpark5m 31s
-
(Locked)
Handle nulls in PySpark8m 39s
-
(Locked)
Use sortBy and orderBy in PySpark9m 38s
-
(Locked)
Use groupBy and aggregation in PySpark8m 27s
-
(Locked)
Manipulate strings in PySpark14m 21s
-
(Locked)
Handle date manipulation in PySpark9m 37s
-
(Locked)
Handle timestamp manipulation in PySpark4m 29s
-
-
-
-
-
-
-
-
-
-
-
-