Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Вивчайте The Most Profitable Periods | Analyzing Data
Analyzing and Visualizing Real-World Data

book
The Most Profitable Periods

Good, now we know that the given data are weekly. Let's find out what weeks were the most profitable by comparing the total for each week.

Завдання

Swipe to start coding

  1. Group the observations in the df dataframe by the 'Date' column values.
  2. Select the 'Weekly_Sales' column.
  3. Calculate the total (sum) for each group.
  4. Sort values in descending order (not ascending).

Рішення

# Loading the library
import pandas as pd

# Reading the data
df = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/72be5dde-f3e6-4c40-8881-e1d97ae31287/shops_data3.csv')
df['Date'] = pd.to_datetime(df['Date'], dayfirst = True)

# Inspecting the data
print(df.groupby('Date')['Weekly_Sales'].sum().sort_values(ascending = False))

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

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

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

Секція 3. Розділ 5
# Loading the library
import pandas as pd

# Reading the data
df = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/72be5dde-f3e6-4c40-8881-e1d97ae31287/shops_data3.csv')
df['Date'] = pd.to_datetime(df['Date'], dayfirst = True)

# Inspecting the data
print(___.___('___')['___'].___().___(ascending = ___))

Запитати АІ

expand
ChatGPT

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

some-alt