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

Subindo_ATV_CASA #19

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions exercicios/para-casa/Resolucao_ATVCASA
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import pandas as pd

file_path = 'C:/Users/alexc/OneDrive/Curso_Python/Reprograma_On33/Semana_11/on33-python-s09-pandas-numpy-I/material/mais_ouvidas_2024.csv'
df = pd.read_csv(file_path)
print(df.head())


numerical_columns = ['Spotify Streams', 'YouTube Views', 'TikTok Views', 'Pandora Streams', 'Soundcloud Streams',
'Spotify Popularity', 'TikTok Likes', 'Shazam Counts']


for col in numerical_columns:
df[col] = df[col].replace({',': ''}, regex=True).astype(float)
print(df[numerical_columns].dtypes)


df['Release Date'] = pd.to_datetime(df['Release Date'], format='%Y-%m-%d')
print(df['Release Date'].head())


df['Streaming Popularity'] = df[['Spotify Popularity', 'YouTube Views', 'TikTok Likes', 'Shazam Counts']].mean(axis=1)
print(df[['Spotify Popularity', 'YouTube Views', 'TikTok Likes', 'Shazam Counts', 'Streaming Popularity']].head())

df['Total Streams'] = df[['Spotify Streams', 'YouTube Views', 'TikTok Views', 'Pandora Streams', 'Soundcloud Streams']].sum(axis=1)
print(df[['Spotify Streams', 'YouTube Views', 'TikTok Views', 'Pandora Streams', 'Soundcloud Streams', 'Total Streams']].head())

filtered_df = df[(df['Spotify Popularity'] > 80) & (df['Total Streams'] > 1_000_000)]
print(filtered_df.head())

filtered_df.to_json('faixas_filtradas.json', orient='records', lines=True)

import os
print(os.path.exists('faixas_filtradas.json'))