0 votes
1 view
in Machine Learning by (4.1k points)

1 Answer

0 votes
by (10k points)
edited by

There are two methods of going ahead with this, one is by hardcoding the data frame, which might get a little tedious when it comes to large datasets. The other way around is to use the functions provided by pandas. 

Here is an explanation for both the methods: 

You can try hardcoding it like this 

df.values
array([[nan, 0.7, nan],
       [nan, 0.65, 0.5],
       [nan, 0.2, 0.5],
       [0.1, 0.2, nan],
       [0.1, 0.2, 0.9],
       [0.6, nan, 0.5],
       [0.1, nan, nan]])

The other way is to use a pandas function for it. These functions work on converting numPy arrays from al sorts of panda objects. This came out with pandas v0.24.0

  1. to_numpy(): Works for index, series and data frame
  2. array: works with index and series only 
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...