Top "Dataframe" questions

A data frame is a 2D tabular data structure.

How to change the order of DataFrame columns?

I have the following DataFrame (df): import numpy as np import pandas as pd df = pd.DataFrame(np.random.rand(10, 5)) …

python pandas dataframe
Convert pandas dataframe to NumPy array

I am interested in knowing how to convert a pandas dataframe into a NumPy array. dataframe: import numpy as np …

python arrays pandas numpy dataframe
How to drop rows of Pandas DataFrame whose value in a certain column is NaN

I have this DataFrame and want only the records whose EPS column is not NaN: >>> df STK_…

python pandas dataframe nan
Set value for particular cell in pandas DataFrame using index

I've created a Pandas DataFrame df = DataFrame(index=['A','B','C'], columns=['x','y']) and got this x y A …

python pandas dataframe
How to convert a data frame column to numeric type?

How do you convert a data frame column to a numeric type?

r dataframe type-conversion
Remove an entire column from a data.frame in R

Does anyone know how to remove an entire column from a data.frame in R? For example if I am …

r dataframe
Create an empty data.frame

I'm trying to initialize a data.frame without any rows. Basically, I want to specify the data types for each …

r dataframe r-faq
How to replace NaN values by Zeroes in a column of a Pandas Dataframe?

I have a Pandas Dataframe as below: itm Date Amount 67 420 2012-09-30 00:00:00 65211 68 421 2012-09-09 00:00:00 29424 69 421 2012-09-16 00:00:00 29877 70 421 2012-09-23 00:00:00 30990 71 421 2012-09-30 00:00:00 61303 72 485 2012…

python pandas dataframe nan
Combine two columns of text in pandas dataframe

I have a 20 x 4000 dataframe in Python using pandas. Two of these columns are named Year and quarter. I'd like …

python pandas dataframe
Get statistics for each group (such as count, mean, etc) using pandas GroupBy?

I have a data frame df and I use several columns from it to groupby: df['col1','col2',…

python pandas dataframe group-by pandas-groupby