Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Data_challenge #24

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

yadavved01
Copy link

No description provided.

@yadavved01
Copy link
Author

The purpose of this code is to calculate the percentage of "positive consent" given for each date in the events data.

Here's a summary of what the code does:

Initializes a Spark session and reads the events data from a JSON file into a DataFrame named "eventsDF".

Filters the events based on their type, so that only "pageview", "consent.given", and "consent.asked" events are kept.

Adds a new column "date" to the filtered events DataFrame by converting the "datetime" field to a date.

Extracts the "enabled purposes" field from the "user.token" field in the events data, and adds a new column "positive_consent" to the DataFrame indicating whether the user has given positive consent (based on the size of the "enabled_purposes" field).

Groups the events by "date" and "positive_consent", counting the number of events for each combination.

Pivots the grouped DataFrame to calculate the percentage of positive consent for each date.

Displays the result DataFrame and stops the Spark session.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant