Sonzaschool
Rudi

Sekondari ya Kawaida · Kidato cha Nne · Amali · Electronics and Computer

Computer Programming

Performing basic data transformations

takriban dakika 5 kusoma

Majadiliano
Mada za sehemu hiiCleaning and organising dataMada 4

Data transformation is the process of changing the structure, format, or values of data to make it more suitable for analysis. In data science and programming, we often need to clean, organize, and reshape our data before we can use it to answer questions or make decisions. This topic covers the basic techniques that every data analyst must know: filtering rows, sorting rows, renaming columns, and creating new calculated columns from existing data.

Filtering means selecting only the rows that meet certain conditions. When working with datasets, we often need to work with a subset of data that satisfies specific criteria.

To filter data in Python using pandas, we use conditions inside square brackets. For example, to select only rows where a column called price is greater than a certain value, we write:

filtered_data = data[data['price'] > 5000]

This reads as: "Give me rows from data where the price column is greater than 5000."

We can combine multiple conditions using:

  • & for AND (both conditions must be true)
  • | for OR (at least one condition must be true)

Example: selecting students who scored above 60 in both Mathematics and English:

passed = data[(data['math'] > 60) & (data['english'] > 60)]

Jinsi utakavyotathminiwaTathmini ya mchakato · Tathmini ya matokeo · Tathmini ya maarifa

Tathmini ya mchakato

  • Manipulate data structures and apply transformations like filtering and sorting.
  • Create meaningful derived variables.

Tathmini ya matokeo

A transformed dataset that meets specified requirements (e.g., sorted, filtered, or with additional features).

Tathmini ya maarifa

Detailed knowledge of:

Method used: The student should explain how to:

  • apply transformations on data

Principles: The student should explain the principles of

  • Reproducibility in data transformations.

Theories: The student should explain:

  • Feature engineering and its role in improving data utility.

Circumstantial knowledge:

Detailed knowledge about:

  • Handling errors when performing complex transformations (e.g., applying functions to entire columns).

Swali

Which pandas expression selects only rows where the age column is greater than 18?

Ingia ili kuwasilisha jibu lako na lihesabiwe katika umahiri wako.

Ingia ili kufanya mazoezi

Mwalimu

Umekwama? Niulize chochote kuhusu mada hii.

Ingia ili kumuuliza Mwalimu wa AI wa Sonza kuhusu swali hili.

Ingia ili kuuliza

Majadiliano

Hakuna maswali bado

Ingia ili kuuliza
Inapakia majadiliano…