Embed row of data from dataframe into single vector or array values

Viewed 205

Is there any way I can embed or any process to capture each of the row data turn into vector, or array number which is in shape (1,)?

enter image description here

My intention is to embed each of the rows information become something to representative input feature, so that I can convert 1x3 shape from DataFrame into 1. For example,

row [1,6,5]  become =====> [2.178] //sample array number only, not necessary 2.178
row [1,10,3] become =====> [3.415] //sample array number only
row [1,12,5] become =====> [0.888] //sample array number only

Is that any libary available? or does my request make sense? Thank you in advance for your view.

To generate data sample,

# Import pandas library 
import pandas as pd 
  
# initialize list of lists 
sample_dat = [[1, 10, 5], [1, 10, 3], [1, 12, 5]] 
  
# Create the pandas DataFrame 
sample_df = pd.DataFrame(sample_dat, columns = ['userId', 'movieId', 'rating'])
0 Answers
Related