Создание массива для задачи и преобразование его в список.
a = np.array([[ 0.00021284, -0.04443965, 0.03926146, 0.04830161,
-0.11913304, 0.03370821],
[ 0.01778569, -0.05192029, -0.00792321, -0.01799901,
-0.09819183, 0.06020728],
[-0.00748426, -0.02401578, 0.01762747, 0.09334017,
-0.11837556, 0.00603597],
[-0.03505319, -0.01932572, -0.03248611, 0.00356432,
-0.082398 , 0.03887841],
[-0.05111802, -0.0309066 , 0.03542011, -0.01343899,
-0.10434885, -0.0315006 ]]).tolist()
Результат:
print(a)
[[0.00021284, -0.04443965, 0.03926146, 0.04830161, -0.11913304, 0.03370821], [0.01778569, -0.05192029, -0.00792321, -0.01799901, -0.09819183, 0.06020728], [-0.00748426, -0.02401578, 0.01762747, 0.09334017, -0.11837556, 0.00603597], [-0.03505319, -0.01932572, -0.03248611, 0.00356432, -0.082398, 0.03887841], [-0.05111802, -0.0309066, 0.03542011, -0.01343899, -0.10434885, -0.0315006]]
Затем добавьте список в фрейм данных.
df = pd.DataFrame({"Message": [
"How are you?",
"What is your name?",
"What do you do?",
"What is your address?",
"Let's hang out?"]})
df['Array'] = a
print(df)
Для:
Message Array
0 How are you? [0.00021284, -0.04443965, 0.03926146, 0.048301...
1 What is your name? [0.01778569, -0.05192029, -0.00792321, -0.0179...
2 What do you do? [-0.00748426, -0.02401578, 0.01762747, 0.09334...
3 What is your address? [-0.03505319, -0.01932572, -0.03248611, 0.0035...
4 Let's hang out? [-0.05111802, -0.0309066, 0.03542011, -0.01343...
Чтобы создать все в начале, вы можете использовать словарь:
df = pd.DataFrame({"Message": [
"How are you?",
"What is your name?",
"What do you do?",
"What is your address?",
"Let's hang out?"], "Array": a})