Skip to content
Open
Show file tree
Hide file tree
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
26 changes: 26 additions & 0 deletions Anália/exercicoS9.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import pandas as pd

df = pd.read_csv("Anália/mais_ouvidas_2024.csv")

print(df.head())
print(df.dtypes)

convertendo_colunas = ['Spotify Streams', 'Spotify Playlist Count', 'Spotify Playlist Reach','YouTube Views', 'YouTube Likes',
'TikTok Posts', 'TikTok Likes', 'TikTok Views','YouTube Playlist Reach', 'AirPlay Spins',
'SiriusXM Spins', 'Deezer Playlist Reach', 'Pandora Streams', 'Pandora Track Stations', 'Soundcloud Streams', 'Shazam Counts']
df[convertendo_colunas] = df[convertendo_colunas].replace({',': ''}, regex=True).astype(float)

print(df.dtypes)

df['Release Date'] = pd.to_datetime(df['Release Date'])

df['Streaming Popularity'] = df[['Spotify Popularity', 'YouTube Views', 'TikTok Likes', 'Shazam Counts']].mean(axis=1)
df['Total Streams'] = df['Spotify Streams'] + df['YouTube Views'] + df['TikTok Views'] + df['Pandora Streams'] + df['Soundcloud Streams']
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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


filtro = (df['Spotify Popularity'] > 80) & (df['Total Streams'] > 1_000_000)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
filtro = (df['Spotify Popularity'] > 80) & (df['Total Streams'] > 1_000_000)
most_popular_filter = (df['Spotify Popularity'] > 80) & (df['Total Streams'] > 1_000_000)

faixas_filtradas = df[filtro]

print(faixas_filtradas)

faixas_filtradas.to_json('faixas_filtradas.json')

Loading