All Questions
80
questions
1
vote
3
answers
58
views
Equivalence between reshape, strides and transpose? (numpy)
i am sorry for the very naive question.
I have these lines of numpy code, with a transpose at the beginning, and strides and reshape are used afterward.
I wonder if by re-ordering indices in reshape ...
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(...
1
vote
1
answer
72
views
Why does .reshape(a, b) != .reshape(b, a).T?
I ran into this problem whilst flattening images. Consider the following array
>>> import numpy as np
>>> arr = np.array([[[1, 2],
[3, 4]],
[[...
1
vote
2
answers
53
views
In R, how to transpose row data to coulmn per variable? [duplicate]
I have some data like below
dataA=data.frame(structure(list(Season = c(2021, 2021, 2021, 2021, 2021, 2022,
2022, 2022, 2022, 2022, 2023, 2023, 2023, 2023, 2023),
...
0
votes
2
answers
23
views
Substituting " points = np.array([x, y]).T.reshape(-1, 1, 2)" with simpler steps
I am trying to generate the output of the following Python statement with simple-enough-to-understand steps, possibly using for-loops. I have studied the .reshape method and what -1 means as a ...
0
votes
1
answer
29
views
R transform data wid while keeping date format - reshape or dcast
Trying to do something so simple and transpose this data wide so for each ID I have the VisitNum {1,2,3} as the column header and the CollectionDate as the value.
At my starting point Collection date ...
0
votes
1
answer
21
views
Transpose dataframe without timevar and with multiple id variables
I have a question similar to a prior post.
Transpose / reshape dataframe without "timevar" from long to wide format
I am trying to transpose a dataset fromn long to wide format. I am ...
1
vote
1
answer
43
views
The recast fun to spread the rows is omitting key columns in R?
I am trying to spread my data such that months are the columns associated with both site and spx. I tried to use recast but I lose the informaton about species. What do I do to get the expected output ...
2
votes
4
answers
706
views
R dplyr pivot wider with duplicates and generate variable names [duplicate]
How can I go from
df<-data.frame(id=c("A", "B", "B"), res=c("one", "two", "three"))
df
to
df.output<-data.frame(id=c("A", &...
2
votes
3
answers
726
views
How to transpose times series data in R so that the date-variable ends up as the new variables names
I have a huge times series dataset (over 500 variables) consisting of monthly observations for several years. See a simplified example of the input data below (in Excel):
Now, what I need to do (in R)...
5
votes
2
answers
2k
views
How to split a numpy array into overlapping tiles?
How can I convert the a array into the b array as they are specified below in Python and using numpy library? I am looking for a very efficient way since my actual array that I want to use this method ...
0
votes
1
answer
2k
views
TypeError: 'generator' object cannot be interpreted as an integer
Traceback Error:
Traceback (most recent call last):
File "C:\trial2\trial.py", line 56, in <module>
image_stack(image)
File "C:\trial2\trial.py", line 44, in ...
0
votes
3
answers
285
views
transpose data in one column based on unique values in another column [duplicate]
I basically would like to do what is described here in r
example data
names<-c("k127_60234", "k127_60234","k127_60234","k127_60234","k127_50234",&...
0
votes
2
answers
100
views
Reshape dataframe in R, different dates
I have data that looks like this:
ID
Name
Role
Status
Date
1
John
GM
Current
12.04.2021
1
Ann
GM
Previous
10.07.2020
1
Mary
GM
Previous
24.01.2017
2
Ann
GM
Current
12.04.2021
2
Josef
GM
Previous
...
0
votes
1
answer
346
views
Reshape/Transpose duplicated rows to column in R studio
I have data that looks like this:
ID
Name
Adress
Score
Requirement
Status
1
John
CA
1
Internet
OK
1
John
CA
1
TV
Not OK
1
John
CA
1
Household
OK
2
Ann
LA
3
Internet
Not OK
2
Ann
LA
3
TV
Follow ...