Questions tagged [reshape]
In R, Matlab, NumPy and APL, reshape functions allow data to be transformed into more convenient forms.
reshape
3,904
questions
4
votes
2
answers
116
views
How to reference the last column in pivot_longer() without naming it or providing the index number?
I'm writing a function to pivot a data table to long format. For the cols = argument, the name of the first column will always be the same, but the final column (and number of columns) will change. ...
1
vote
1
answer
121
views
Convert data from wide to long format by checking the values of a row
I have the data below
data<-structure(list(id = c("R_88j7lG37gLfxk22", "R_6DK8lERVf8lSQf4"
), t1_choice = c("2", "3"), t2_choice = c("1", "3&...
0
votes
0
answers
15
views
Is there any xarray code for selecting data in the shape of a parallelogram?
I have a temperature data with dimensions YC and XC. I'm interested in selecting data within the red parallelogram shape depicted in the figure. xarray.DataArray'YC: 720 XC: 560.
However, when using ...
0
votes
1
answer
165
views
numpy reshape implementation
My main focus will on this page.
First, I don't understand the page. For the first parameter shape,
ndarray.reshape(shape, order='C')
why this method on ndarray allows the elements of the shape ...
0
votes
0
answers
17
views
Received a label value of 3 which is outside the valid range of [0, 2)
# Consider increasing epochs for better performance
import numpy as np
X = np.array(X,dtype='float64')
y = np.array(y, dtype ='float64')
model.fit(X, y,epochs=10)
test_loss, test_acc = model.evaluate(...
3
votes
2
answers
93
views
Reshaping a data frame with example
I am trying to reshape my data frame. I have my data in long columns, and I need to spread that data out into the same row but new columns, as you can see above.
One of the main problems I am running ...
0
votes
1
answer
38
views
How to reshape Quanteda corpus by values of a docvar?
I'm working with a text corpus in R using the quanteda package. Suppose this corpus contains some texts that are split into sentences. Using corpus_reshape() it is easy enough, in theory, to switch ...
1
vote
3
answers
143
views
Reshape a stacked style data file into a dataframe using pandas
I have a csv input file with the below format and i'm looking for a fairly easy way to convert to normal shape dataframe in pandas. the csv data file has all data stacked up into two columns with each ...
1
vote
3
answers
72
views
Long and wide format exercise
I have the following issue:
given the following sample dataset:
structure(list(idpat = c("1", "2", "2", "1", "1"), idA = c("100a",
"...
0
votes
1
answer
58
views
2D representation of a 1D input sample in deep learning
I want to design a 2D-CNN model for the dataset called "CICIoT2023". I will provide the link to this data set : https://www.unb.ca/cic/datasets/iotdataset-2023.html
This data set is divided ...
1
vote
3
answers
100
views
"Reshape" along a specific axis - Numpy
I have a 4D numpy array. For example I have 2 batches of 3 two-dimensional matrices with a shape of (2, 3, 4, 5).
In each batch, I want to concatenate the three 2D matrices horizontally (over the last ...
1
vote
0
answers
56
views
ValueError: Exception encountered when calling layer 'sequential' (type Sequential) in multivariate prediction
i have ran these code to train for model of LSTM multivariate attribute, it will predict "rain", "humidity" , "pressure" in 1 model, but then i receive this error:
...
1
vote
2
answers
167
views
How can I transpose a gtsummary tbl_summary object?
In my hypothetical scenario, 100 people are asked: What is your favorite color of car, shirt, and website (red, blue, or yellow)? This yields my mock data frame:
colors <- c("red", "...
1
vote
1
answer
62
views
reshape problem in R: it does not consider all variables
I read this question about reshape and I tryed to use on my dataset.
But when I use it, my new dataset doen't have all the column requested and repeat some variables.
My actual dataset is like this:
...
0
votes
1
answer
39
views
Reshape object with shape (500,)
I'm using the following code to reshape an object with shape (625,):
u1 = np.linspace(16, 20, 25)
u2 = np.linspace(16, 20, 25)
u1, u2 = np.meshgrid(u1, u2)
U = np.vstack((u1.flatten(), u2.flatten()))
...