100% de satisfacción garantizada Inmediatamente disponible después del pago Tanto en línea como en PDF No estas atado a nada 4.2 TrustPilot
logo-home
Resumen

Summary Python Data Operations 3: Filtering

Puntuación
-
Vendido
-
Páginas
10
Subido en
09-12-2022
Escrito en
2022/2023

Notes of Pandas data operations covered in the Principles of Programming course, part of the Computer Science and AI bachelor degree. The notes are initially written in Jupyter Notebook. They contain practical examples of data operations in python and images to explain the structures and processes. This third section contains: - Conditional Selection - pd.Series and Operators - Basic Filters - Missing Values - Identify Nulls - Filter Nulls - Fill in Nulls - Remove Nulls - Unique Values

Mostrar más Leer menos









Ups! No podemos cargar tu documento ahora. Inténtalo de nuevo o contacta con soporte.

Información del documento

¿Un libro?
No
¿Qué capítulos están resumidos?
Pandas data wrangling
Subido en
9 de diciembre de 2022
Número de páginas
10
Escrito en
2022/2023
Tipo
Resumen

Temas

Vista previa del contenido

Python Data Operations 3: Filtering
(Using the numpy and pandas packages imported in section one.)

This third section contains:

Conditional Selection
pd.Series and Operators
Basic Filters
Missing Values

Identify Nulls
Filter Nulls
Fill in Nulls
Remove Nulls
Unique Values
# create test dataframe
test_df = pd.DataFrame([
['A3', 0, -1, 0, 'si'],
['B1', 1, None, 0, 'no'],
['B3', 4, None, 0, 'no'],
['B3', 5, 1, 0, 'si'],
['A1', 4, 0, None, None],
['A3', 1, 2, 1, 'si'],
['C2', 4, 1, 1, 'no']],
columns=['A', 'B', 'C', 'D', 'E'],
index=[f'R{i}' for i in range(7)]
)
test_df


A B C D E

R0 A3 0 -1.0 0.0 si

R1 B1 1 NaN 0.0 no

R2 B3 4 NaN 0.0 no

R3 B3 5 1.0 0.0 si

R4 A1 4 0.0 NaN None

R5 A3 1 2.0 1.0 si

R6 C2 4 1.0 1.0 no




Conditional selection
In pandas conditional selection is filtering some records according to certain criteria

, The syntax is df[filter] where filter is a sequence of boolean values of the same length
as the table, and the command allows us to select/filter records according to a certain
condition.



# create simple filter
filter = [True, True, False, False, True, True, False]
filter

[True, True, False, False, True, True, False]


# apply simple filter
# .iloc and .loc are equivalent here
test_df.iloc[filter, :]
test_df.loc[filter, :]


A B C D E

R0 A3 0 -1.0 0.0 si

R1 B1 1 NaN 0.0 no

R4 A1 4 0.0 NaN None

R5 A3 1 2.0 1.0 si



# filter columns containing a list of column names
columns = ['A', 'B', 'C']
# apply columns filter
test_df.loc[:, columns]
test_df[columns] #equivalent to previous line
6,99 €
Accede al documento completo:

100% de satisfacción garantizada
Inmediatamente disponible después del pago
Tanto en línea como en PDF
No estas atado a nada

Conoce al vendedor
Seller avatar
beatricemossberg
3,0
(1)

Documento también disponible en un lote

Thumbnail
Package deal
Python Data Operations summarised notes (all notebooks)
-
2 5 2022
€ 34,95 Más información

Conoce al vendedor

Seller avatar
beatricemossberg IE University
Ver perfil
Seguir Necesitas iniciar sesión para seguir a otros usuarios o asignaturas
Vendido
2
Miembro desde
3 año
Número de seguidores
2
Documentos
11
Última venta
2 año hace
Computer Science and Data Notes

3,0

1 reseñas

5
0
4
0
3
1
2
0
1
0

Recientemente visto por ti

Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes