from pyspark.sql import SparkSession
from pyspark.sql import functions as F

spark = SparkSession.builder.appName("transport").getOrCreate()

path = "s3://dtpm-transactions/parquet/"

df = spark.read.parquet(path)
result = df.select("nombreentidad", "nombresitio", F.date_format('fechahoratrx', 'yyyy-MM-dd').
                   alias('day')).groupby('nombreentidad', 'nombresitio', 'day').count()

output_path = "s3://dtpm-transactions/result.csv"
# result.coalesce(1).write.csv(path)
result. \
    repartition(1). \
    write. \
    mode("overwrite"). \
    format("com.databricks.spark.csv"). \
    option("header", "true").save("result.csv")

aca4aa62ef7c9c764a82dfdd169966458aed6e09
<mask token>

<mask token>
result.repartition(1).write.mode('overwrite').format('com.databricks.spark.csv'
    ).option('header', 'true').save('result.csv')

<mask token>
spark = SparkSession.builder.appName('transport').getOrCreate()
path = 's3://dtpm-transactions/parquet/'
df = spark.read.parquet(path)
result = df.select('nombreentidad', 'nombresitio', F.date_format(
    'fechahoratrx', 'yyyy-MM-dd').alias('day')).groupby('nombreentidad',
    'nombresitio', 'day').count()
output_path = 's3://dtpm-transactions/result.csv'
result.repartition(1).write.mode('overwrite').format('com.databricks.spark.csv'
    ).option('header', 'true').save('result.csv')

from pyspark.sql import SparkSession
from pyspark.sql import functions as F
spark = SparkSession.builder.appName('transport').getOrCreate()
path = 's3://dtpm-transactions/parquet/'
df = spark.read.parquet(path)
result = df.select('nombreentidad', 'nombresitio', F.date_format(
    'fechahoratrx', 'yyyy-MM-dd').alias('day')).groupby('nombreentidad',
    'nombresitio', 'day').count()
output_path = 's3://dtpm-transactions/result.csv'
result.repartition(1).write.mode('overwrite').format('com.databricks.spark.csv'
    ).option('header', 'true').save('result.csv')

from pyspark.sql import SparkSession
from pyspark.sql import functions as F

spark = SparkSession.builder.appName("transport").getOrCreate()

path = "s3://dtpm-transactions/parquet/"

df = spark.read.parquet(path)
result = df.select("nombreentidad", "nombresitio", F.date_format('fechahoratrx', 'yyyy-MM-dd').
                   alias('day')).groupby('nombreentidad', 'nombresitio', 'day').count()

output_path = "s3://dtpm-transactions/result.csv"
# result.coalesce(1).write.csv(path)
result. \
    repartition(1). \
    write. \
    mode("overwrite"). \
    format("com.databricks.spark.csv"). \
    option("header", "true").save("result.csv")
