<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Merge and split columns
Sometimes we need to merge multiple columns in a Dataframe into one column, or split a column into multiple columns. We can easily achieve this by converting a DataFrame to RDD, applying map functions to manipulate elements, and then converting the RDD back to a DataFrame.
Example data frame
Step1:  Merge multiple columns
We convert DataFrame to RDD and then apply the map function to merge values and convert 
elements to Row objects.
Step2:  Then we create a new DataFrame from the obtained RDD.
Step3:  Split one column
We use the above DataFrame as our example data. Again, we need to convert the DataFrame to an RDD to achieve our goal.
Let's split the values column into two columns
<ASSISTANT_TASK:>
Python Code:
mtcars = spark.read.csv(path='../../data/mtcars.csv',
                        sep=',',
                        encoding='UTF-8',
                        comment=None,
                        header=True, 
                        inferSchema=True)
mtcars.show(n=5)
# adjust first column name
colnames = mtcars.columns
colnames[0] = 'model'
mtcars = mtcars.rdd.toDF(colnames)
mtcars.show(5)
Explanation: Merge and split columns
Sometimes we need to merge multiple columns in a Dataframe into one column, or split a column into multiple columns. We can easily achieve this by converting a DataFrame to RDD, applying map functions to manipulate elements, and then converting the RDD back to a DataFrame.
Example data frame
End of explanation
from pyspark.sql import Row
mtcars_rdd = mtcars.rdd.map(lambda x: Row(model=x[0], values=x[1:]))
mtcars_rdd.take(5)
Explanation: Merge multiple columns
We convert DataFrame to RDD and then apply the map function to merge values and convert 
elements to Row objects.
End of explanation
mtcars_df = spark.createDataFrame(mtcars_rdd)
mtcars_df.show(5, truncate=False)
Explanation: Then we create a new DataFrame from the obtained RDD.
End of explanation
mtcars_rdd_2 = mtcars_df.rdd.map(lambda x: Row(model=x[0], x1=x[1][:5], x2=x[1][5:]))
# convert RDD back to DataFrame
mtcars_df_2 = spark.createDataFrame(mtcars_rdd_2)
mtcars_df_2.show(5, truncate=False)
Explanation: Split one column
We use the above DataFrame as our example data. Again, we need to convert the DataFrame to an RDD to achieve our goal.
Let's split the values column into two columns: x1 and x2. The first 4 values will be in column x1 and the remaining values will be in column x2.
End of explanation
<END_TASK>