ok, as I'm not getting much assistance with my original question I thought I would try and figure out the problem myself. So I rewrote the pyspark.sql as follows:
from pyspark.sql import SparkSession
spark = SparkSession.builder.appName('ops').getOrCreate()
df = spark.read.csv('/home/packt/Downloads/Spark_DataFrames/Person_Person.csv',inferSchema=True,header=True)
myresults = spark.sql("""SELECT
,COUNT(PersonType) AS `Person Count`
GROUP BY PersonType""")
result = myresults.collect()
However, I'm now getting the following error message:
AttributeError: 'list' object has no attribute 'saveAsTextFile'
I think this could be an easier situation to help resolve.
So, if someone could help resolve this issue that would be most appreciated