Registrations Closing Soon for DevOps Certification Training by CloudxLab | Registrations Closing inEnroll Now
Although Pandas provides better ways and constructs to load a dataset from various sources like files, databases, etc. we should also know the NumPy constructs for the same.
There are two ways (constructs) in NumPy to load data from a text file:
loadtxt() function provides less flexibility, whereas
genfromtxt() function provides more flexibility.
genfromtxt() function also handles the missing values kind of scenarios in the loaded dataset, whereas
loadtxt() function doesn't.
import numpy as np name_arr, address_arr, zipcode_arr = np.loadtxt('my_file.txt', skiprows=2, unpack=True)
The above piece of code will load the data from
my_file.txt text file.
skiprows=2 means, skip the first two rows of the
my_file.txt file while loading the data.
unpack=True means, unpack the columns of the dataset being loaded and return the data of each column separately in separate arrays ( name column data in
name_arr array, address column data in
address_arr array, zipcode column data in
unpack=False means, return only a single array as output from the
No hints are availble for this assesment
Answer is not availble for this assesment