Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Challenge: Core Contexts select vs with_columns | Paradigm Shift, Selection
Data Wrangling with Polars
Section 1. Chapter 4
single

single

Challenge: Core Contexts select vs with_columns

Swipe to show menu

Task

Swipe to start coding

Implement the function calculate_positive_ratio(df: pl.DataFrame) -> pl.DataFrame.

  • Inside the function, use the .with_columns() method on the DataFrame.

  • Construct an expression that divides Positive by the sum of Positive and Negative.

  • Name the resulting column Positive Ratio.

Solution

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 1. Chapter 4
single

single

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

some-alt