Top "Dataframe" questions

A data frame is a 2D tabular data structure.

Select first 4 rows of a data.frame in R

How can I select the first 4 rows of a data.frame: Weight Response 1 Control 59 0.0 2 Treatment 90 0.8 3 Treatment 47 0.1 4 Treamment 106 0.1 5 Control 85 0.7 6 Treatment 73 0.6 7 Control 61 0.2

r dataframe
Add column to dataframe with constant value

I have an existing dataframe which I need to add an additional column to which will contain the same value …

python pandas dataframe
For each row in an R dataframe

I have a dataframe, and for each row in that dataframe I have to do some complicated lookups and append …

r dataframe rows
How to store a dataframe using Pandas

Right now I'm importing a fairly large CSV as a dataframe every time I run the script. Is there a …

python pandas dataframe
How to access the last value in a vector?

Suppose I have a vector that is nested in a dataframe one or two levels. Is there a quick and …

r dataframe vector
Sum rows in data.frame or matrix

I have a very large dataframe with rows as observations and columns as genetic markers. I would like to create …

r dataframe matrix rowsum
Combining two Series into a DataFrame in pandas

I have two Series s1 and s2 with the same (non-consecutive) indices. How do I combine s1 and s2 to …

python pandas series dataframe
How do I retrieve the number of columns in a Pandas data frame?

How do you programmatically retrieve the number of columns in a pandas dataframe? I was hoping for something like: df.…

python pandas dataframe
Using Pandas to pd.read_excel() for multiple worksheets of the same workbook

I have a large spreadsheet file (.xlsx) that I'm processing using python pandas. It happens that I need data from …

python excel pandas dataframe
Pandas read_csv low_memory and dtype options

When calling df = pd.read_csv('somefile.csv') I get: /Users/josh/anaconda/envs/py27/lib/python2.7/site-packages/pandas/io/…

python parsing numpy pandas dataframe