R: How can I reshape my data.frame from wide to long using a Date variable?

Advertisements Edit: This question was closed, but it is different than its predecessors as it concerns a time series and the answer provided is so convenient that I believe it will help many beginners who don’t know how to use the arguments correctly for a time series. How can I reshape my data frame so… Read More R: How can I reshape my data.frame from wide to long using a Date variable?

How can I melt a dataframe from wide to long twice on the same column?

Advertisements I have a dataframe: data = [ [1, "2022-04-29", 123, "circle", 1, 3, 6, 7.3], [1, "2022-02-10", 456, "square", 4, np.nan, 3, 9], ] df = pd.DataFrame( data, columns=[ "ID", "date", "code", "shape", "circle_X_rating", "circle_Y_rating", "square_X_rating", "square_Y_rating", ], ) df ID date code shape circle_X_rating circle_Y_rating square_X_rating square_Y_rating 1 2022-04-29 123 circle 1 3.0… Read More How can I melt a dataframe from wide to long twice on the same column?

Reshape strings within a dataframe in R

Advertisements I have a dataframe that looks like this data.frame(service=c("1,2,3,4","2,4,5","1,3,4"), score=c("1,2,1,3","1,1,3","1,1,1")) a b 1 1,2,3,4 1,2,1,3 2 2,4,5 1,1,3 3 1,3,4 1,1,1 The variable service refers to a categorical variable from 1-5, while the score, is also a categorical variable from 1-3 for each of the previous service. Note that each respondent have taken different… Read More Reshape strings within a dataframe in R

Can not reshape 2 dimensional array to 3 dimensional array for RNN in python

Advertisements I can not reshape the array into 3-dimensional one. Here is the example dataset: import pandas as pd import numpy as np df = { "a": [0.06 , 0.07, 0.45, 0.98, 0.97 ], "b": [12,45,65, 56, 34], "c": [2,5,5, 5, 3], "d": [23,55,25, 15, 34], "e": [0.0005,0.55555,0.383825, 0.4747477415, 0.348344334], "f": [0.0236 , 0.3407, 0.4545,… Read More Can not reshape 2 dimensional array to 3 dimensional array for RNN in python

Merge wide and long dataset into wide dataset in R (by combining certain column headers and certain cells into new column headers)

Advertisements I’ve 2 datasets Participant performance: 1 participant/row Participant ratings: >1 participants/row (1 rater/row) I need to merge the 2 datasets into 1 dataset with 1 participant/row (including NAs). I’ve included reproducible toy examples of the 2 datasets I have as well as a reproducible toy example of the merged dataset that I need below.… Read More Merge wide and long dataset into wide dataset in R (by combining certain column headers and certain cells into new column headers)