PR Atividade11Semana11#9
Open
nathalialp28 wants to merge 1 commit into
Open
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')) |
Collaborator
There was a problem hiding this comment.
porque usar o apply se o str.replace + astype já faz o que é preciso?
Author
There was a problem hiding this comment.
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
Collaborator
There was a problem hiding this comment.
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') |
Collaborator
There was a problem hiding this comment.
também é possível fazer com:
Suggested change
| 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) |
Collaborator
There was a problem hiding this comment.
mean() = média
median() = mediana
Suggested change
| 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Entrega da atividade 11 da semana 11 Profa. Manuelly - Turma ON33
Tema: ETL com Pandas [tipagem, filtragem]