Top "Dataframe" questions

A data frame is a 2D tabular data structure.

Shuffle DataFrame rows

I have the following DataFrame: Col1 Col2 Col3 Type 0 1 2 3 1 1 4 5 6 1 ... 20 7 8 9 2 21 10 11 12 2 ... 45 13 14 15 3 46 16 17 18 3 ... The DataFrame is read from a csv file. All rows which …

python pandas dataframe permutation shuffle
Add new row to dataframe, at specific row-index, not appended?

The following code combines a vector with a dataframe: newrow = c(1:4) existingDF = rbind(existingDF,newrow) However this code always inserts …

r dataframe insert
Why isn't my Pandas 'apply' function referencing multiple columns working?

I have some problems with the Pandas apply function, when using multiple columns with the following dataframe df = DataFrame ({'a' : …

python python-2.7 pandas dataframe apply
Split data frame string column into multiple columns

I'd like to take data of the form before = data.frame(attr = c(1,30,4,6), type=c('foo_and_bar','foo_and_…

r string dataframe split r-faq
Drop unused factor levels in a subsetted data frame

I have a data frame containing a factor. When I create a subset of this dataframe using subset or another …

r dataframe r-factor r-faq
Combine two or more columns in a dataframe into a new column with a new name

For example if I have this: n = c(2, 3, 5) s = c("aa", "bb", "cc") b = c(TRUE, FALSE, TRUE) df = data.…

r dataframe multiple-columns r-faq
Determine the number of NA values in a column

I want to count the number of NA values in a data frame column. Say my data frame is called …

r dataframe
Insert a row to pandas dataframe

I have a dataframe: s1 = pd.Series([5, 6, 7]) s2 = pd.Series([7, 8, 9]) df = pd.DataFrame([list(s1), list(s2)], columns = ["A", "B", "…

python pandas dataframe insert
Convert data.frame column to a vector?

I have a dataframe such as: a1 = c(1, 2, 3, 4, 5) a2 = c(6, 7, 8, 9, 10) a3 = c(11, 12, 13, 14, 15) aframe = data.frame(a1, a2, a3) I tried …

r dataframe vector type-conversion
Convert list of dictionaries to a pandas DataFrame

I have a list of dictionaries like this: [{'points': 50, 'time': '5:00', 'year': 2010}, {'points': 25, 'time': '6:00', 'month': "february"}, {'points':90, …

python dictionary pandas dataframe