How do I convert a pandas dataframe to a numpy array using python?

0 votes

How do I convert a pandas dataframe to a numpy array using python?

May 22, 2019 in Machine Learning by Anu
604 views

1 answer to this question.

0 votes

Try something like this:

df.values
array([[nan, 0.2, nan],
       [nan, nan, 0.5],
       [nan, 0.2, 0.5],
       [0.1, 0.2, nan],
       [0.1, 0.2, 0.5],
       [0.1, nan, 0.5],
       [0.1, nan, nan]])
answered May 22, 2019 by Krishti

Related Questions In Machine Learning

0 votes
1 answer

How to convert 1D array into 2D array using pandas?

Hi@akhtar, You can follow the below given codes to ...READ MORE

answered May 8 in Machine Learning by MD
• 33,540 points
238 views
0 votes
1 answer

not able to see all columns and rows of a pandas DataFrame?

Hi@akhtar, Your data set contains lots of rows ...READ MORE

answered Apr 8 in Machine Learning by MD
• 33,540 points
162 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

How to create Pandas series from numpy array?

Hi. Refer to the below command: import pandas ...READ MORE

answered Apr 1, 2019 in Python by Pavan
716 views
0 votes
1 answer
0 votes
1 answer

How to create Pandas series from dictionary?

Here's a sample script: import pandas as pd import ...READ MORE

answered Apr 1, 2019 in Python by Prateek
160 views
0 votes
1 answer

How to convert pandas dataframe to numpy array?

Irrespective of whether the dataframe has similar ...READ MORE

answered May 12, 2019 in Python by Rishi
5,161 views
0 votes
1 answer

How do I create a decision tree?

Let us consider the following example. Suppose a ...READ MORE

answered May 13, 2019 in Machine Learning by Fatima
155 views
0 votes
1 answer

Example to run KNN algorithm using python

Have a look at this one: from sklearn.datasets ...READ MORE

answered May 8, 2019 in Machine Learning by Harvy
382 views