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
2 answers
44 views

pivot longer by looping over certain columns

I have the following data which belongs to my darts league in wide format structure(list(home_team = c("Art of Dart", "Art of Dart", "Art of Dart", "Art of Dart&...
Emre Toros's user avatar
-1 votes
1 answer
52 views

How to convert data from wide to long format in R with a separating dot

I have my data in wide format and I would convert it to long format. Here is a sample of the data data <- structure(list(lsoa11 = c("E01000001", "E01000002", "E01000003&...
OLu's user avatar
  • 77
0 votes
3 answers
101 views

How can I combine multiple columns into a single column and create another column indicating the source?

I am trying to turn a table that looks like this: record_id height_1 height_1_v1 height_1_v1_v1 weight_1 weight_1_v1 weight_1_v1_v1 10 NA NA 5ft6in NA NA 154 10 5ft6in NA NA 152 NA NA 10 NA 5ft6in ...
ktbkr's user avatar
  • 1
0 votes
0 answers
39 views

Reshape factor levels to columns (no action on values)

I need some help reshaping my dataframe. I just want each level of my factor "Season" to become 2 new columns and the values come from the column "den" (no summing or averaging of ...
Nate's user avatar
  • 553
-1 votes
1 answer
152 views

ValueError: Expected 2D array

I try to make a SVC. from sklearn.svm import SVC import numpy as np import pandas as pd import matplotlib.pyplot as plt df = pd.read_csv("iris.csv") df.loc[df["species"]=="...
Joo's user avatar
  • 37
0 votes
0 answers
79 views

In R, when transpose data from row to column, why spread() code doesn't work?

I have a data below dataA= data.frame( Location = rep(c("East", "West", "North"), each = 12 * 2), Season = rep(rep(c(2021, 2022), each = 6), 3), Genotype = rep(rep(...
Jin.w.Kim's user avatar
  • 884
0 votes
1 answer
68 views

reshape problem in LogisticRegression code

I try to make a LogisticRegression. import pandas import matplotlib.pyplot as plt from sklearn.linear_model import LogisticRegression import numpy as np df = pd.read_csv("tested.csv") df....
Joo's user avatar
  • 37
1 vote
2 answers
74 views

how to transform double matrix into dataframe columns

i'm trying to reshape some square double matrix into some columns dataframe something like: genomeA genomeB genomeC genomeA 1.0 0.5 0.3 genomeB 0....
Marine Bergot's user avatar
1 vote
1 answer
45 views

Merge dataframes and fill gaps with duplicated columns and corresponding dates

I have three dataframes (df1, df2 and df3). I would like to merge them and also, fill each others gaps. For example: df1 contains USA data from 1990 to 1993 and df2 from 1994 to 1999. When I merge ...
Drop's user avatar
  • 339
1 vote
3 answers
58 views

table of proportions in R taking into account unique persons

I have 3 people in a study. They are asked to pick up as many items of fruit as they wish. I then want to count the times each fruit was picked up and create a proportion using the number of ...
Basil's user avatar
  • 986
0 votes
1 answer
44 views

How to you concat inner matrixes of tensor along axis?

Let we have a tensor with shape $n\times d\times h\times w\times p\times p$ and we want to concat innet matrix with shape $p\time p$, such that we made a matrix with shape $n\times d\times ph\times pw$...
Samvel Safaryan's user avatar
0 votes
1 answer
90 views

reshaping rows and columns and then converting to numpy array

Following DataFrame contains integer values. I want them to reshaped into a new column where every row will be represented, as a combination of each 3 rows of each columns from old dataframe. import ...
Rupak's user avatar
  • 39
0 votes
1 answer
45 views

reshaping table with excel

I have the next table in excel |Id |name |last name |boss |boss mail | ______________________________________________ |id1|name1|last name1|boss1|boss mail1| |id2|name2|last name2|boss2|boss mail2| |...
Gonzalo S's user avatar
0 votes
1 answer
47 views

Numpy reshape image to column major order is duplicating my picture

For Self supervised learning purpose, I need to create a dataset composed of custom pictures. I want to store my pictures in a bin file, as numpy array in the shape (3, 256, 256) in column major order....
Willy Lutz's user avatar
0 votes
2 answers
77 views

Reshape long to wide table in SQL

I have a dataset with variables ID, Vaccine, and Date. Some Vaccines have a single date, and some vaccines have two or three dates for a single ID. When I create a table in SQL, multiple rows are ...
user12501522's user avatar

15 30 50 per page
1
3 4
5
6 7
261