All Questions

55
votes
10answers
175935 views

Convert multiple rows into one with comma as separator

If I issue SELECT username FROM Users I get this result: username -------- Paul John Mary but what I really need is one row with all the values separated by comma, like this: Paul, John, Mary ...
484
votes
10answers
515673 views

How to iterate over rows in a DataFrame in Pandas?

I have a DataFrames from pandas: import pandas as pd inp = [{'c1':10, 'c2':100}, {'c1':11,'c2':110}, {'c1':12,'c2':120}] df = pd.DataFrame(inp) print df Output: c1 c2 0 10 100 1 11 110 2 ...
100
votes
11answers
150672 views

Compare two data.frames to find the rows in data.frame 1 that are not present in data.frame 2

I have the following 2 data.frames: a1 <- data.frame(a = 1:5, b=letters[1:5]) a2 <- data.frame(a = 1:3, b=letters[1:3]) I want to find the row a1 has that a2 doesn't. Is there a built in fun...
7
votes
4answers
7309 views

How to delete rows from a dataframe that contain n*NA

I have a number of large datasets with ~10 columns, and ~200000 rows. Not all columns contain values for each row, although at least one column must contain a value for the row to be present, I would ...
3
votes
2answers
1183 views

remove IDs that occur x times R

I have a df and I would like to remove people who have less than X amount of rows in df. E.g., in this toy example, I would like to retain people who have >= 5 rows. df names fruit 4 john ki...
83
votes
5answers
228360 views

How to append rows to an R data frame

I have looked around StackOverflow, but I cannot find a solution specific to my problem, which involves appending rows to an R data frame. I am initializing an empty 2-column data frame, as follows. ...
45
votes
9answers
51671 views

Repeat rows of a data.frame

I want to repeat the rows of a data.frame, each N times. The result should be a new data.frame (with nrow(new.df) == nrow(old.df) * N) keeping the data types of the columns. Example for N = 2: ...
15
votes
2answers
31754 views

Compare Python Pandas DataFrames for matching rows

I have this DataFrame (df1) in Pandas: df1 = pd.DataFrame(np.random.rand(10,4),columns=list('ABCD')) print df1 A B C D 0.860379 0.726956 0.394529 0.833217 0.014180 ...
16
votes
4answers
76641 views

Removing specific rows from a dataframe

I have a data frame e.g.: sub day 1 1 1 2 1 3 1 4 2 1 2 2 2 3 2 4 3 1 3 2 3 3 3 4 and I would like to remove specific rows that can be ...
3
votes
4answers
43520 views

Create text Files from every row in an Excel spreadsheet

I need help creating separate text files from each row in an excel spread sheet called "worksheet". I want the text files to be named with content of Column A, with columns B-G being the content, pre...

Previous Next