I have a two-dimensional tensor and I want to make a Dataframe with one column out of it so that it doesn't split into separate values.
Something like that:
import torch
import pandas as pd
x = torch.rand(4,3)
x
>>> tensor([[0.8888, 0.8168, 0.2737],
[0.9429, 0.0847, 0.6115],
[0.3147, 0.5715, 0.9937],
[0.5592, 0.7696, 0.3094]])
df = pd.DataFrame(x)
df
>>> tensor([0.8888, 0.8168, 0.2737])
tensor([0.9429, 0.0847, 0.6115])
tensor([0.3147, 0.5715, 0.9937])
tensor([0.5592, 0.7696, 0.3094])
df.shape
>>> (4, 1)
Help me, please, I will be very grateful.
I tried to use a cycle to add tensors by rows. I tried converting it to an array first. It is constantly evolving into separate values in each column.