I was wondering if it is possible to change the position of a column in a dataframe, actually to change the schema?
Precisely if I have got a dataframe like [f
Like others have commented, I'm curious to know why would you do this as the order is not relevant when you can query the columns by their names.
Anyway, using a select should give the feeling the columns have moved in schema description:
val data = Seq(
("a", "hello", 1),
("b", "spark", 2)
)
.toDF("field1", "field2", "field3")
data
.show()
data
.select("field3", "field2", "field1")
.show()