Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Вивчайте Challenge: Visualize Social Media Engagement | Data Analysis and Visualization for Media
Python for Journalists and Media

bookChallenge: Visualize Social Media Engagement

In digital journalism, understanding which stories resonate with your audience is essential for editorial decisions and resource allocation. Social media platforms generate vast amounts of engagement data—such as likes, shares, and comments—that can reveal which articles are catching the public's attention. By analyzing this data, you can quickly spot high-impact stories and trends.

123456789101112131415161718192021222324252627
import pandas as pd # Example DataFrame representing social media engagement for news articles data = { 'title': [ 'Elections 2024: What You Need to Know', 'Local Hero Saves Family', 'City Council Approves New Park', 'Breaking: Major Storm Hits Coast', 'Economic Forecast for Next Year', 'Investigation: Water Quality Concerns', 'Sports Update: Championship Results' ], 'likes': [1200, 950, 600, 1800, 750, 500, 1100], 'shares': [300, 150, 90, 450, 120, 80, 200], 'comments': [85, 60, 45, 130, 50, 40, 90] } df = pd.DataFrame(data) # Calculate total engagement df['total_engagement'] = df['likes'] + df['shares'] + df['comments'] # Sort by total engagement, descending sorted_df = df.sort_values(by='total_engagement', ascending=False) print(sorted_df[['title', 'total_engagement']])
copy

Visualizing the engagement data is a powerful way to communicate which stories are truly making an impact. By creating a bar chart of the top-performing articles, newsrooms can easily identify which content is driving the most conversation and tailor their editorial strategies accordingly. This approach not only highlights popular topics but also helps teams allocate resources to stories with the greatest reach and relevance.

Завдання

Swipe to start coding

Write a function that analyzes social media engagement for news articles using the predefined DataFrame. Your function must:

  • Calculate the total engagement for each article by adding the likes, shares, and comments columns.
  • Identify the top 5 articles with the highest total engagement.
  • Create a bar chart showing the total engagement for each of these top 5 articles, using the article titles as labels.
  • Return a DataFrame containing the top 5 articles and their engagement metrics.

Рішення

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 2. Розділ 3
single

single

Запитати АІ

expand

Запитати АІ

ChatGPT

Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат

Suggested prompts:

Can you show me how to create a bar chart for this engagement data?

How can I identify trends or patterns in the engagement data?

What other metrics could be useful for analyzing article performance?

close

bookChallenge: Visualize Social Media Engagement

Свайпніть щоб показати меню

In digital journalism, understanding which stories resonate with your audience is essential for editorial decisions and resource allocation. Social media platforms generate vast amounts of engagement data—such as likes, shares, and comments—that can reveal which articles are catching the public's attention. By analyzing this data, you can quickly spot high-impact stories and trends.

123456789101112131415161718192021222324252627
import pandas as pd # Example DataFrame representing social media engagement for news articles data = { 'title': [ 'Elections 2024: What You Need to Know', 'Local Hero Saves Family', 'City Council Approves New Park', 'Breaking: Major Storm Hits Coast', 'Economic Forecast for Next Year', 'Investigation: Water Quality Concerns', 'Sports Update: Championship Results' ], 'likes': [1200, 950, 600, 1800, 750, 500, 1100], 'shares': [300, 150, 90, 450, 120, 80, 200], 'comments': [85, 60, 45, 130, 50, 40, 90] } df = pd.DataFrame(data) # Calculate total engagement df['total_engagement'] = df['likes'] + df['shares'] + df['comments'] # Sort by total engagement, descending sorted_df = df.sort_values(by='total_engagement', ascending=False) print(sorted_df[['title', 'total_engagement']])
copy

Visualizing the engagement data is a powerful way to communicate which stories are truly making an impact. By creating a bar chart of the top-performing articles, newsrooms can easily identify which content is driving the most conversation and tailor their editorial strategies accordingly. This approach not only highlights popular topics but also helps teams allocate resources to stories with the greatest reach and relevance.

Завдання

Swipe to start coding

Write a function that analyzes social media engagement for news articles using the predefined DataFrame. Your function must:

  • Calculate the total engagement for each article by adding the likes, shares, and comments columns.
  • Identify the top 5 articles with the highest total engagement.
  • Create a bar chart showing the total engagement for each of these top 5 articles, using the article titles as labels.
  • Return a DataFrame containing the top 5 articles and their engagement metrics.

Рішення

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 2. Розділ 3
single

single

some-alt