How to convert a list into an array in Python

0 votes

Hi Guys,

I am new to Machine Learning. I have one list. I want to convert the list into a NumPy array. How can I do that?

Oct 15, 2020 in Python by akhtar
• 38,170 points
124 views

1 answer to this question.

0 votes

Hi@akhtar,

You need to import the NumPy module in your code. This module can convert a list into an array as shown below.

db = [['abc',10,20],['def',30,40],['ghi',40,50]]
import numpy
arr = numpy.array(db)
answered Oct 15, 2020 by MD
• 95,180 points

Related Questions In Python

0 votes
1 answer

How can I convert a list of dictionaries from a CSV into a JSON object in Python?

You could try using the AST module. ...READ MORE

answered Apr 17, 2018 in Python by anonymous
2,263 views
+1 vote
1 answer

How to convert records from csv to a list in Python?

If you are using Python 3.x then ...READ MORE

answered Jun 25, 2019 in Python by Arvind
• 3,000 points

edited Jun 26, 2019 by Kalgi 5,758 views
0 votes
1 answer

How to convert each list item into string in a column of data frame. ?

Hey, To split a string you can use ...READ MORE

answered Feb 5, 2020 in Python by Roshni
• 10,440 points
240 views
+4 votes
7 answers
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 2,077 views
0 votes
0 answers
0 votes
1 answer
0 votes
1 answer

How to convert a dataframe into list?

Hi@akhtar, You can convert your dataframe into list. ...READ MORE

answered Apr 24, 2020 in Python by MD
• 95,180 points
122 views