Skip to main content

All Questions

Tagged with
1 vote
1 answer
56 views

Reshape Pandas Dataframe and group by 2 level columns

I have a dataframe with flat structure of having unique Rows as follow. I need to reshape it as shown below. Using Pivot table and swapping levels, I managed to obtain somewhat closer to the result, ...
rush dee's user avatar
  • 336
0 votes
1 answer
36 views

Reshape seems to be losing observations

i am using reshape in dplyr to turn a long data table into a wide one. but when i do, i seem to be losing some observations. the data table called "data" is a record of 6 different species ...
colby tanner's user avatar
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", "...
user3483060's user avatar
0 votes
1 answer
39 views

Reshape data with multiple columns to long format [duplicate]

I'm pretty sure, that a question like this was asked before but I cannot find any. This is my dataset: data.frame(Group = c("a", "b"), MEAN_A = 1:2, MEAN_B =...
TobiSonne's user avatar
  • 1,086
1 vote
1 answer
3k views

Pandas pivot_table dropped a column, although no aggregation is done, only reshape

Im trying to use Pandas pivot_table function to reshape my data-frame. But it fails on specific rows and I get the message: FutureWarning: pivot_table dropped a column because it failed to aggregate. ...
user2424097's user avatar
0 votes
1 answer
34 views

Using pivot_wider in R to reshape biomarkHD data?

I have the following snippet of my dataframe. The values aren't important. I am trying to get it to wide form using pivot_wider. Dataset id_1 <- c("S78-A01", "S78-A04", "...
lmrogers34's user avatar
0 votes
2 answers
96 views

Reshape time series data from wide to long for multiple variables

I'm working with time series data in wide(ish) format for many columns that all have the format "T1_v1_slow"..."T4_v1_slow" and "T1_v1_fast"..."T4_v1_fast". ...
walkabilly's user avatar
0 votes
1 answer
110 views

Convert to long form in R based on column names which include sequential numbers in names

I have a data frame where each row includes multiple "observations" with data on the same set of variables, of which each set is appended with a number (e.g., age, gender, code, age.1, ...
zhg's user avatar
  • 11
0 votes
1 answer
82 views

Opening and reshaping xlsx files with nameless columns in r using a pattern

I'm working with French electoral data but I'm having issues opening xlsx files to work on them in r. I was wondering if anyone had had the same problem and found a solution. The issue is that only ...
LLS's user avatar
  • 59
1 vote
2 answers
492 views

r wide to long to wide

This is a version of my dataset ID Name n Mean_SD q2 q1_q3 Range 1 A 1477 3.42(15.12) 0.8 0.4,1.9 0 - 343.7 1 B 1475 127.114 (668.781) ...
Ahir Bhairav Orai's user avatar
1 vote
2 answers
302 views

How to reshape a dataframe to a pivot table, including per-row totals and keeping two-level headers

I want to reshape my dataframe so I can pivot the 'kind' field, but I also want to include per-row aggregations. df = pd.DataFrame([ { 'date': '2022-04-20', 'kind': 'alpha', ...
VFS's user avatar
  • 21
1 vote
1 answer
436 views

How to reshape a Pivot Table?

I am trying to "reshape" a pivot table: I would like to remove those MultiIndex: This should be my output: I have already tried stack, unstack, melt, but I am not getting the result. At ...
V_Notaro's user avatar
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", &...
ECII's user avatar
  • 10.6k
1 vote
1 answer
307 views

Add a calculated column to a pivot table in pandas

Hi I am trying to create new columns to a multi-indexed pandas pivot table to do a countif statement (similar to excel) depending if a level of the index contains a specific string. This is the ...
Martin Petrov's user avatar
0 votes
0 answers
9 views

Convert a DataFrame, similar to pivot_table, without aggregating a cell [duplicate]

I have a Pandas DataFrame of the following format: model Interpretability Diversity AUC num_topics LDA 0.123 0.41 0.61 5 LDA 0.234 0.42 ...
Emil's user avatar
  • 1,662

15 30 50 per page