how to transform comma separated column into multiples rows in db2

You really should not be storing data like this. Fortunately, there is a way to undo the damage with recursive SQL, something along these lines: WITH unpivot (lvl, id, fk_ref, reference, tail) AS ( SELECT 1, id, fk_ref, CASE WHEN LOCATE(‘,’,reference) > 0 THEN TRIM(LEFT(reference, LOCATE(‘,’,reference)-1)) ELSE TRIM(reference) END, CASE WHEN LOCATE(‘,’,reference) > 0 THEN … Read more

How to append rows to an R data frame

Update Not knowing what you are trying to do, I’ll share one more suggestion: Preallocate vectors of the type you want for each column, insert values into those vectors, and then, at the end, create your data.frame. Continuing with Julian’s f3 (a preallocated data.frame) as the fastest option so far, defined as: # pre-allocate space … Read more

How to remove rows with any zero value

There are a few different ways of doing this. I prefer using apply, since it’s easily extendable: ##Generate some data dd = data.frame(a = 1:4, b= 1:0, c=0:3) ##Go through each row and determine if a value is zero row_sub = apply(dd, 1, function(row) all(row !=0 )) ##Subset as usual dd[row_sub,]

Compare Python Pandas DataFrames for matching rows

One possible solution to your problem would be to use merge. Checking if any row (all columns) from another dataframe (df2) are present in df1 is equivalent to determining the intersection of the the two dataframes. This can be accomplished using the following function: pd.merge(df1, df2, on=[‘A’, ‘B’, ‘C’, ‘D’], how=’inner’) For example, if df1 … Read more