-
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
Atividade de casa - S11 #8
base: main
Are you sure you want to change the base?
Conversation
if df[col].dtype == 'object': | ||
df[col] = pd.to_numeric(df[col].str.replace(',', '', regex=True), errors='coerce') |
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.
já que se deu ao trabalho de criar a num_cols
manualmente, porque está fazendo esse código e porque optou pelo uso do to_numeric()
ao invés do astype()
? 🤔
|
||
|
||
# Corrigindo a coluna 'Release Date' para o formato datetime | ||
df['Release Date'] = pd.to_datetime(df['Release Date'], errors='coerce') |
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.
o que o parâmetro errors='coerce'
faz?
for col in sum_cols: | ||
if col not in df.columns: | ||
print(f"Coluna {col} não encontrada no DataFrame.") |
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.
você converteu todas elas para float logo acima, não?
print(df.dtypes) | ||
|
||
# Verificando se todas as colunas envolvidas na soma são numéricas | ||
sum_cols = ['Spotify Streams', 'YouTube Views', 'TikTok Views', 'Pandora Streams', 'Soundcloud Streams'] |
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.
sum_cols = ['Spotify Streams', 'YouTube Views', 'TikTok Views', 'Pandora Streams', 'Soundcloud Streams'] | |
streams_cols = ['Spotify Streams', 'YouTube Views', 'TikTok Views', 'Pandora Streams', 'Soundcloud Streams'] |
filtered_df.to_json('faixas_filtradas.json', orient='records', lines=True) | ||
|
||
# Verificando se o arquivo JSON foi salvo corretamente | ||
import os |
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.
os imports vão no começo do código
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
No description provided.