0
0
NumPydata~10 mins

np.genfromtxt() for handling missing data in NumPy - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to load data from 'data.csv' using numpy's genfromtxt.

NumPy
import numpy as np
data = np.genfromtxt('data.csv', delimiter=[1])
Drag options to blanks, or click blank then click option'
A,
B;
C:
D|
Attempts:
3 left
💡 Hint
Common Mistakes
Using semicolon or other characters as delimiter when the file uses commas.
2fill in blank
medium

Complete the code to skip the first row (header) when loading data.

NumPy
data = np.genfromtxt('data.csv', delimiter=',', [1]=1)
Drag options to blanks, or click blank then click option'
Askip_header
Busecols
Cskip_footer
Ddtype
Attempts:
3 left
💡 Hint
Common Mistakes
Using skip_footer instead of skip_header.
Not skipping header and getting errors or wrong data.
3fill in blank
hard

Fix the error in the code to correctly handle missing values represented by 'NA'.

NumPy
data = np.genfromtxt('data.csv', delimiter=',', skip_header=1, [1]='NA')
Drag options to blanks, or click blank then click option'
Amissing
Bfilling_values
Cinvalid_raise
Dmissing_values
Attempts:
3 left
💡 Hint
Common Mistakes
Using filling_values instead of missing_values to specify missing data.
Not specifying missing values and getting errors.
4fill in blank
hard

Complete the code to load data, skip header, and replace missing values with 0.

NumPy
data = np.genfromtxt('data.csv', delimiter=,, skip_header=[1], filling_values=0)
Drag options to blanks, or click blank then click option'
A,
B;
C1
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong delimiter or skip_header value.
Not using filling_values to replace missing data.
5fill in blank
hard

Fill both blanks to load data, skip header, specify missing values as 'NA', and fill them with -1.

NumPy
data = np.genfromtxt('data.csv', delimiter=,, skip_header=[1], missing_values=[2], filling_values=-1)
Drag options to blanks, or click blank then click option'
A,
B1
C'NA'
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Not specifying missing_values correctly.
Using wrong delimiter or skip_header values.