FAQ: Introduction to NumPy - Creating an Array from a CSV

This community-built FAQ covers the “Creating an Array from a CSV” exercise from the lesson “Introduction to NumPy”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Data Science

Introduction to Statistics with NumPy

FAQs on the exercise Creating an Array from a CSV

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

Do you always have to specify a delimiter or is there a default delimiter if you don’t specify one?


1 Like

What are the better way to handle data (e.g. get a series of data frame) ? Use Pandas or Numpy command np.getfromtxt() ?

wondering why this would not work. I used pandas to create a list from the csv, then changed it to an array using numpy. I thought it would print the same elements as in the list. Thanks

#[79, 100, 86, 93, 91]

#Index: []

Why don’t we import the file test_2.csv in this exercise?

#[79, 100, 86, 93, 91]

This would works

According to the documentation of numpy.genfromtxt(), it is optional and the default value is None. By default any consecutive whitespaces seem to act as delimiter.

delimiter str, int, or sequence, optional
The string used to separate values. By default, any consecutive whitespaces act as delimiter. An integer or sequence of integers can also be provided as width(s) of each field.