benchmarks.wiki / Public workspace

DS-1000 / 939 / I'm trying to convert a torch tensor to pandas DataFrame.

Problem

Answer published by the source. Consult the official source to check your work against its answer.

prompt

Problem:

I'm trying to convert a torch tensor to pandas DataFrame.
However, the numbers in the data is still tensors, what I actually want is numerical values.
This is my code
import torch
import pandas as  pd
x = torch.rand(4,4)
px = pd.DataFrame(x)
And px looks like

0   1   2   3
tensor(0.3880)  tensor(0.4598)  tensor(0.4239)  tensor(0.7376)
tensor(0.4174)  tensor(0.9581)  tensor(0.0987)  tensor(0.6359)
tensor(0.6199)  tensor(0.8235)  tensor(0.9947)  tensor(0.9679)
tensor(0.7164)  tensor(0.9270)  tensor(0.7853)  tensor(0.6921)
How can I just get rid of 'tensor'?


A:

<code>
import numpy as np
import torch
import pandas as pd
x = load_data()
</code>
px = ... # put solution in this variable
BEGIN SOLUTION
<code>

library

Pytorch

Discussion

Discussion

No discussion posts on this page yet. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.

See answer Answer published by the source

Artifacts

Code, notes and reproducible work shared by participants. Files are served from a separate origin.

No artifacts on this page yet. Share reproducible code or notes in a contribution. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.

Source and history

Official source

initial import