Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
0 votes
2 answers
60 views

Expand a dataframe row into multiple rows based on string conditions

I have some raw data similar to the dataframe below: df = pd.DataFrame([{'var1': '220-224 (Even) roadname1', 'var2': 'location 1', 'var3': 'area 1'}, {'var1': 'site of 5 to 9 (odd) ...
suzanne's user avatar
  • 49
1 vote
2 answers
90 views

How to expand multiple list column in rows in python

I have a DataFrame like this: ID MS DS 654 1500,10000,20000,30000 60,365,730 131 1500,10000,20000 60,365,730 598 1500,10000,20000,30000 60,365,730 The desired output looks like this: ID MS DS 654 1500 ...
Divyansh Kumar Singh's user avatar
1 vote
1 answer
16 views

Create a dataframe by fixing rows in one column and repeating other columns

Lets say I have three variables: var1<-c(101,102,103,104) var2<-c("AB","XY") var3<-c(1,2) X<-expand.grid(var1,var2,var3) X Above code gives this output Var1 Var2 ...
vp_050's user avatar
  • 508
0 votes
2 answers
98 views

R: grouping and expanding the data.frame to include only possible pairs of names in a column

My goal is to expand my data.frame in R to include possible combinations (but not all possible combinations) from a column in R. Similar to the expand.grid command, but that function gives you all ...
Purrsia's user avatar
  • 896
1 vote
2 answers
68 views

How to get the cartesian product?

I have a data frame like this: plazo monto 20 2 50 3 I need to add a rows for values between 1 to the value of plazo and expand my dataframe like below; plazo monto Semana 20 2 1 20 2 2 20 2 3 20 2 … ...
RONHI's user avatar
  • 13
0 votes
1 answer
147 views

`Error in seq.int` while expanding dataframe using start and end dates

*edit: I have provided dput() sample data at the bottom of page. I have a large dataframe that I am trying to expand. Specifically, I want to use the start and end date columns to produce a row for ...
lwe's user avatar
  • 381
0 votes
1 answer
36 views

R dyplr::complete nesting with part of combination

first time I post after two weeks of trying everything. I need to complete a set of data (500 000 lines) for graph. For the example, there is 3 parkings and different type of car per parking. When ...
Johnnn's user avatar
  • 1
0 votes
2 answers
7k views

ValueError: Columns must be same length as key - when working on one row only

I am trying to add columns to the DataFrame based on the splitting of one column. With two rows, everything works and the empty column takes the value 'None'. The problem when I only have one row and ...
homel's user avatar
  • 3
0 votes
3 answers
79 views

Expanding within the same df

I am looking for expanding my dataset based on any number e.g., (5) I have the following data set import pandas as pd df = pd.DataFrame({"X": ["A", "B" ], "Y": [...
Ahmed's user avatar
  • 17
1 vote
3 answers
191 views

expand a 2 by 2 contingency table

I have loaded data in the following format: Gender Yes No Male 2 1 Female 1 2 I would like to expand it to: Gender Result Male Yes Male Yes Male No Female Yes Female No Female No I've tried using the ...
code_rookie's user avatar
2 votes
1 answer
830 views

Python: Expand dataframe rows with specific column value in terms of 1/8th

Have got input dataframe like below: df Store Item Space 11 Grape 0.125 11 Beans 0.0 12 Mango 0.25 13 Beetroot 0.375 13 Carrot 0.5 Need to ...
user12345's user avatar
  • 509
0 votes
1 answer
2k views

Python: How to expand column with list of values to multiple rows? [duplicate]

Have got a df which looks like this: Item Match a bb,cc b dd,ee want to expland the column 'Match' as below: Item Match a bb a cc b dd b ee tried df.explode(...
user12345's user avatar
  • 509
0 votes
1 answer
89 views

Expand information in one dataframe and link with data from other

Lets say I have dataframe as such: df1 Index Id ABC [1227, 33234] DEF [112, 323, 2223, 231239] GHI [9238294, 213, 2398219] And another one: df2 Id variable 112 500 213 ...
vbadvd's user avatar
  • 21
0 votes
2 answers
331 views

How to expand a dataframe in R with a continuous variable? [duplicate]

I have this dataset: group_ask <- c('A', 'A', 'B', 'B', 'C', 'C') number_ask <- c(1, 3, 2, 4, 5, 8) df_ask <- data.frame(group_ask, number_ask) I am trying to expand the group_ask column by ...
sebastian.klotz's user avatar
0 votes
2 answers
527 views

Expand Pandas Dataframes adding rows by different ranges

I have a dataframe like this: SEG FAM GAMA MIN_RAT MAX_RAT VALOR PE 001 002 1 2 5,15 PE 001 002 2,1 3 2,55 And I need to "expand" the df adding new rows to make a new dataframe like this: ...
Daniel Caldevilla Domínguez's user avatar

15 30 50 per page