 Hello, welcome to SSUnitech, Sushil this site and this is continuation of PySpark tutorial. So in this video we are going to see about the cast. So what is the cast inside the PySpark? So cast is nothing but it is going to use for converting the data type of any column. So cast we can use with column and we can also use with select expression. So we are going to see in this video for both. So let me quickly go inside the browser and we will try to see in practical. So here I am going to create one of the data frame and this data frame will be having name is job start date is graduate, gender and salary. So all these columns will be having in this data frame. And here I am going to print the schema of this data frame. So here we can simply check what is the data type of all these columns. So here we can see for the name we have the string data type for the is we have long then we have string string string and for salary we have double. So now let me try to convert the data type of the is as string and job start date as date is graduate as Boolean. So how we can do that? So simply we can use the cast function. So first let me try to import all these functions. So simply we can use the from PySpark dot SQL dot functions then import as thick. So it will import all the function. Now let me try to also import the data type. So we can use the from PySpark dot SQL dot types import as thick. So what these two lines will do, it will be going to import all the SQL type function and types. So types is nothing but the data type. Now we have one of the data frame that we have created that is the DF as we can see here. Now we need to replace the is. So let me use the data frame DF dot then we can use the with column. So simply inside the with column I'm going to replace the existing column which is the is but here I'm going to update the data type. So simply we can use the column by which we want to do the update. So that is the DF dot is dot we can use the cast. So cast function will help us to update it here it is asking about the type. So which data type we want to add I'm going to convert this into the string data type. So we can use the string type like that. So let me try to put this into another data frame that is DF one and simply let me try to replace the data type of one more column. And this column is job start date that we can see here. So this job start date we just want to replace from string to date. So here we can use this job start date and this will be job start date and after cast instead of the string type this should be data type. So we can add the data type like this. Let me try to replace one more. I'm going to replace for the is graduate and this will be the Boolean type. So here we can use the is graduate. And here I'm going to replace the existing one is graduate. And here instead of the date type this should be Boolean type. Now here we can execute all good. We can expand this and we can check the data types. So for the is graduate we can see the Boolean for the job start date. We have date for the is it is converted to a string. So simply we can use the with column. We can specify the existing column in the first parameter in the second parameter. We can add the data frame dot your column name by which you just want to convert. And then we can use the cost and inside the cast we can use the actual data type that we just want to put. So simply we can use it. The second way we can also use the select expression. So how we can use the select expression. Let me try to compete this from here and let me go here in this new cell. And here we can use the df dot select expression and he will be in caps. Now here we have to specify all the columns which is available in the existing data frame. Then we will just want to add few additional columns. We can add this double code and inside that we can use the cast and here is as a string. So it is going to work as SQL statement. And after that we can also provide the alias of this. So this will be going to add a one more column with the is and let me try to put this in another data frame. And here let me execute it and we can expand here and we'll see and verify new as is converted to the string. So this is the one way by which we can also implement it. So either we can go with this way or we can go with the first one. So I prefer to use the first one. Here we are going to replace the existing column only updating the data type of those column. Thank you so much for watching this video. If you like this video please subscribe our channel to get many more videos. See you in the next video.