Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
学ぶ Challenge: Extract and Report Key Insights | Automating Reports and Visual Insights
Python Automation for Reports and Visual Insights
セクション 1.  26
single

single

bookChallenge: Extract and Report Key Insights

メニューを表示するにはスワイプしてください

タスク

スワイプしてコーディングを開始

Create a function extract_significant_changes(df, threshold) that accepts a DataFrame with a value column and a numeric threshold, identifies all points where the value changed significantly compared to the previous row, prints a summary report, and returns the list of changes.

Loop through the value column using .items() to access both the index and value. For each row after the first, compare it to the previous value — if the absolute difference is greater than threshold, record the change.

For each significant change, store:

  • index — the current row's index
  • prev_index — the previous row's index
  • prev_value — the previous value
  • current_value — the current value
  • change — the difference (current minus previous, can be negative)

Print a summary report in this exact format:

Significant changes (threshold: {threshold}):
At {index}, value changed from {prev_value} to {current_value} (change: {change})
At {index}, value changed from {prev_value} to {current_value} (change: {change})
...

For example, given values [100, 110, 90, 92, 130] with threshold=15, the output should be:

Significant changes (threshold: 15):
At 2, value changed from 110 to 90 (change: -20)
At 4, value changed from 92 to 130 (change: 38)

Return the list of recorded change dictionaries at the end of the function.

解答

Switch to desktop実践的な練習のためにデスクトップに切り替える下記のオプションのいずれかを利用して、現在の場所から続行する
すべて明確でしたか?

どのように改善できますか?

フィードバックありがとうございます!

セクション 1.  26
single

single

AIに質問する

expand

AIに質問する

ChatGPT

何でも質問するか、提案された質問の1つを試してチャットを始めてください

some-alt