-
Notifications
You must be signed in to change notification settings - Fork 32
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
Semana 11, pandas #16
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GG
|
||
# 2 - Indentifique as colunas que contêm números, como 'Spotify Streams', 'YouTube Views', etc., e converta essas colunas para o tipo numérico se estiverem em outro formato. (Use replace() e astype()) | ||
|
||
colunas = ['Track', 'Album Name', 'Artist', 'Release Date', 'ISRC','All Time Rank', 'Track Score', 'Spotify Streams','Spotify Playlist Count', 'Spotify Playlist Reach','Spotify Popularity', 'YouTube Views', 'YouTube Likes', 'TikTok Posts','TikTok Likes', 'TikTok Views', 'YouTube Playlist Reach','Apple Music Playlist Count', 'AirPlay Spins', 'SiriusXM Spins','Deezer Playlist Count', 'Deezer Playlist Reach','Amazon Playlist Count', 'Pandora Streams', 'Pandora Track Stations','Soundcloud Streams', 'Shazam Counts', 'TIDAL Popularity','Explicit Track'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Se essas são todas as colunas , por que não utilizar o df.columns()?
for col in colunas: | ||
if df_musicas[col].dtypes == 'object': | ||
df_musicas[col] = df_musicas[col].str.replace(',' , '').astype(float, errors='ignore') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cuidado ao utilizar você precisou utilizar o erros=ignore porque esta tentando converter colunas do tipo object que de fato são object
|
||
# 4 - Crie uma nova coluna chamada 'Streaming Popularity', que seja a média da popularidade nas plataformas 'Spotify Popularity', 'YouTube Views', 'TikTok Likes', e 'Shazam Counts'. (lembrem-se que só é possível calcular médias e fazer operações matemáticas com tipos númericos) | ||
|
||
df_musicas ['Streaming Popularity'] = df_musicas[['Spotify Popularity', 'YouTube Views', 'TikTok Likes', 'Shazam Counts']].median(axis=1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
df_musicas ['Streaming Popularity'] = df_musicas[['Spotify Popularity', 'YouTube Views', 'TikTok Likes', 'Shazam Counts']].median(axis=1) | |
df_musicas ['Streaming Popularity'] = df_musicas[['Spotify Popularity', 'YouTube Views', 'TikTok Likes', 'Shazam Counts']].mean(axis=1) |
median() mede a mediana, no caso o que você precisa é a média 😄
Exercício de ETL com pandas, utilizando uma lista dos artistas mais ouvidos do SPOTIFY!