-
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
PR Atividade11Semana11 #9
base: main
Are you sure you want to change the base?
Conversation
# colunas com tipagem incorreta: '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'], | ||
|
||
colunas_tipagem = ['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_mais_ouvidas[colunas_tipagem] = df_mais_ouvidas[colunas_tipagem].apply(lambda x: x.str.replace(',', '').astype('float')) |
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.
porque usar o apply se o str.replace + astype
já faz o que é preciso?
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.
utilizei para a construção do lambda e ele procurar item a item do df. Não sei se é a melhor forma, mas entendi que utilizar o lambda aqui para que ele percorresse todos os itens
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.
Sim, o apply é muito bom para diversos casos e você fez o uso do ˋlambdaˋ corretamente. Mas nesse caso adicionar o apply não adianta muita coisa , mesmo sem ele o resultado é o mesmo. 😃
#-------------------------------------------------------------------------------------------------------- | ||
|
||
# print(df_mais_ouvidas.dtypes) | ||
df_mais_ouvidas['Release Date'] = pd.to_datetime(df_mais_ouvidas['Release Date'], format='mixed') |
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.
também é possível fazer com:
df_mais_ouvidas['Release Date'] = pd.to_datetime(df_mais_ouvidas['Release Date'], format='mixed') | |
df_mais_ouvidas['Release Date'] = pd.to_datetime(df_mais_ouvidas['Release Date'], format='%m/%d/%YYYY') |
#-------------------------------------------------------------------------------------------------------- | ||
|
||
colunas_popularidade = ['Spotify Popularity', 'YouTube Views', 'TikTok Likes', 'Shazam Counts'] | ||
df_mais_ouvidas['Streaming Popularity'] = df_mais_ouvidas[colunas_popularidade].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.
mean() = média
median() = mediana
df_mais_ouvidas['Streaming Popularity'] = df_mais_ouvidas[colunas_popularidade].median(axis=1) | |
df_mais_ouvidas['Streaming Popularity'] = df_mais_ouvidas[colunas_popularidade].mean(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.
GG
Entrega da atividade 11 da semana 11 Profa. Manuelly - Turma ON33
Tema: ETL com Pandas [tipagem, filtragem]