Pyspark: display a spark data frame in a table format
The show method does what you’re looking for. For example, given the following dataframe of 3 rows, I can print just the first two rows like this: df = sqlContext.createDataFrame([(“foo”, 1), (“bar”, 2), (“baz”, 3)], (‘k’, ‘v’)) df.show(n=2) which yields: +—+—+ | k| v| +—+—+ |foo| 1| |bar| 2| +—+—+ only showing top 2 rows