Question: Is it possible and what would be the most efficient neat method to add a column to Data Frame? 

More specifically, column may serve as Row IDs for the existing Data Frame.

In a simplified case, reading from file and not tokenizing it, I can think of something as below (in Scala), but it completes with errors (at line 3), and anyways doesn't look like the best route possible: 

```
var dataDF = sc.textFile("path/file").toDF() 
val rowDF = sc.parallelize(1 to DataDF.count().toInt).toDF("ID") 
dataDF = dataDF.withColumn("ID", rowDF("ID")) 

```

Answer: 
not sure if it works in spark 1.3 but in spark 1.5 I use withColumn:

```
import sqlContext.implicits._
import org.apache.spark.sql.functions._

df.withColumn("newName",lit("newValue"))

```

I use this when I need to use a value that is not related to existing columns of the dataframe

This is similar to @NehaM's answer but simpler
You can use [row\_number](https://spark.apache.org/docs/2.0.2/api/java/org/apache/spark/sql/functions.html#row_number()) with [Window function](https://databricks.com/blog/2015/07/15/introducing-window-functions-in-spark-sql.html) as below to get the distinct id for each rows in a dataframe.

```
df.withColumn("ID", row_number() over Window.orderBy("any column name in the dataframe"))

```

You can also use `monotonically_increasing_id` for the same as 

```
df.withColumn("ID", monotonically_increasing_id())

```

And there are some [other ways](https://hadoopist.wordpress.com/2016/05/24/generate-unique-ids-for-each-rows-in-a-spark-dataframe/) too.