Skip to main content

Questions tagged [reshape]

In R, Matlab, NumPy and APL, reshape functions allow data to be transformed into more convenient forms.

0 votes
0 answers
48 views

Pandas move levels of a composite column as a value

Let's imagine as a starting point I have a dataframe, similar to the one below (using a tuple for the composite columns): Index, (ATop,AMiddle,ABottom,filt1_1, filt2_1), (ATop,AMiddle,ABottom,filt1_2,...
georgi koyrushki's user avatar
0 votes
0 answers
89 views

reshape a tensor in firebase cloud functions

Im working on a machine learning project and since I don't know the amount of categories in the dependend variables I don't want to hardcode it. In my project now I have 3 different categories but I ...
chrispsv's user avatar
  • 655
3 votes
3 answers
84 views

Convert vector to matrix by blocks -reshape

just a quick question I am struggling in R to convert a list of numbers to a matrix that has a fixed number of rows and the numbers are placed in triplets (blocks of 3 rows) at a time The elements are ...
chriliv's user avatar
  • 33
0 votes
3 answers
46 views

How can I add a dimension to Torch tensor with values of first two dimensions repeated in the new dimension

I have a Tensor of shape [a,b]. How can I reshape it to [a,b,c] such that all the values along the new dimensions repeat values of the i,j entry of the original tensor of shape [a,b]? ex: a = 2, b= 3 ...
Lrom's user avatar
  • 13
0 votes
2 answers
40 views

pivot_longer with multiple columns with different column name patterns and count column [duplicate]

I have looked at multiple posts but have not seen this exact situation addressed. The linked examples have more consistent variable names (not single/multiple underscores) and do not add the count ...
Agnes Flack's user avatar
-1 votes
1 answer
56 views

Numpy reshape() to display 2D array in 3D programmatically

Example Data I have an array of weather data by lat/lon in the following shape: (1038240,4) (See photo for sample example data) I want to reshape this to the shape (4,721,1440) which would be four ...
Declan's user avatar
  • 3
0 votes
0 answers
18 views

how to build a vae without reshape error?

I build a VAE following https://blog.tensorflow.org/2019/03/variational-autoencoders-with.html PROBLEM: I thick the problem is in the decoder when I want to reshape the latent Distribution i face this ...
mmd-ghamgosar's user avatar
1 vote
1 answer
26 views

Converting two 2d arrays of different shapes into a 3d array

How to convert two 2d arrays of shapes (629, 5) and (629, 6) into a 3d array of shape (629, 5, 6)? Input: [[2, 5, 6, 7, 8], [3, 5, 6, 7, 8], [4, 5, 6, 7, 8]] [[2, 5, 6, 7, 8, 9], [3, 5, 6, 7, 8, 9]...
Rebel's user avatar
  • 495
0 votes
1 answer
42 views

cannot reshape array of size 4 into shape (4,4) in DataFrame where clause

Can anyone explain to me what is going on? Here's the piece of code. If I have the DataFrame of precisely length 4, the statement in the try clause throws an exception. If I make the dataframe of any ...
user23873134's user avatar
1 vote
1 answer
32 views

Given a few block matrices, get the overall large matrix

In short, we are given a 4D tensor y of shape ( B // s2, D2 // s1, s1, s2), where y[i,j,...] represents a matrix of shape (s1,s2). These are the block matrices used to construct the overall large ...
Goldenalcheese's user avatar
0 votes
1 answer
60 views

Keep all matched rows when reshaping from long to wide

I am trying to reshape my data from long to wide format. I would like to keep all rows that match for sn3=1 and sn3=2 instead of taking only the first value. How can I achieve this? Desired output: ...
Victoria's user avatar
0 votes
0 answers
20 views

wide data with part of column name as value [duplicate]

I have the following data structure in R DE_GDP DE_INFL US_GDP US_INFL 1 1 1 1 1 2 2 2 2 2 3 3 3 3 3 4 4 4 4 4 ...
Rkid's user avatar
  • 33
0 votes
3 answers
47 views

calculate annual cases after reshaping dataframe in R

I am working in R and I want to calculate the last column Annual_Cases based on the available years for each surgeon. The variable Years was reported per each 3-year time interval. Some surgeons were ...
Mohamed Rahouma's user avatar
0 votes
3 answers
72 views

How to append value of every two columns in R?

go from m <- matrix(1:16, nrow = 4) [,1] [,2] [,3] [,4] [1,] 1 5 9 13 [2,] 2 6 10 14 [3,] 3 7 11 15 [4,] 4 8 12 16 to 1x16 matrix 1 5 2 6 3 7 4 8 9 ...
dunbesscolder's user avatar
0 votes
0 answers
43 views

Is there a more effective way to create new columns from row values in a Pandas DataFrame? [duplicate]

Given a dataframe with three initial columns, one of which has categorical type with two categories, the aim is to create distinct columns for each category and subsequently store within them the ...
ciranzo's user avatar
  • 57

15 30 50 per page