I\'m looking for a way to get the last character from a string in a dataframe column and place it into another column.
I have a Spark dataframe that looks like this:
One way is by using Column substr() function:
df = df.withColumn("lastchar", df.animal.substr(-1,1))
See documentation: https://spark.apache.org/docs/2.1.0/api/python/pyspark.sql.html#pyspark.sql.Column.substr