Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprenda True News and Fake News | Identifying Fake News
Identifying Fake News

book
True News and Fake News

We will now start working on our project. The final goal of our analysis is to predict whether the given news is fake or true. You will handle text data and build ML (Machine Learning) algorithms.

Tarefa

Swipe to start coding

  1. Read the CSV files containing fake news and true news into their respective DataFrames.
  2. Set the values of the target column 'class' to 0 for the fake_news DataFrame and to 1 for the true_news DataFrame.
  3. Use the appropriate function to merge these two DataFrames.
  4. Display the first 5 rows of the resulting DataFrame using the appropriate method.

Solução

import pandas as pd

# Read the CSV files into DataFrames
fake_news = pd.read_csv(
'https://content-media-cdn.codefinity.com/projects/ef7b5b8f-99b5-4289-8380-5a7ba3adedc5/Fake.csv')
true_news = pd.read_csv(
'https://content-media-cdn.codefinity.com/projects/ef7b5b8f-99b5-4289-8380-5a7ba3adedc5/True.csv')

# Set the values of the target column
fake_news['class'] = 0
true_news['class'] = 1

# Merge two DataFrames
news_merged = pd.concat([fake_news, true_news], axis=0).reset_index(drop=True)

# Display the first 5 rows of news_merged
news_merged.head()

Mark tasks as Completed
Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 1. Capítulo 2
AVAILABLE TO ULTIMATE ONLY
some-alt