Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

equivalent of R's View for Python's pandas

The View is a very useful function to allow me to see cross-section of large data frames in R.

Is there any equivalent of R's View function for Python's pandas DataFrame?

I use RStudio for R and PyCharm for Python.

like image 712
uday Avatar asked Feb 17 '14 16:02

uday


People also ask

Is there a dplyr for Python?

Dplython. Package dplython is dplyr for Python users. It provide infinite functionality for data preprocessing.

Is Pandas similar to dplyr?

Learn More. Heey great post, but pandas has very similar functions as dplyr. If you use those instead, you get statements very similar to your dplyr statements and you would get the same readability.

Is Pandas R or Python?

Developers describe Pandas as "High-performance, easy-to-use data structures and data analysis tools for the Python programming language".


2 Answers

A quicker option might be to set the pandas dataframe so it doesn't line wrap by putting this line of code:

import pandas pandas.set_option('expand_frame_repr', False) 

I'm using Sublime Text 2 and this is how it looks:

Before putting in option (Notice how the output wraps the text around) Before

After putting in option (Notice how the output continues) After

Also make sure that 'View' > 'Word Wrap' is not checked.

Additionally, you can print out more or less as you need by using head(#) like this:

mydf = pandas.DataFrame.from_csv('myfile.csv', header=1) print mydf.head(20) # Prints first 20 lines 

Here's some other pandas options:

pandas.set_option('display.max_columns', 0) # Display any number of columns pandas.set_option('display.max_rows', 0) # Display any number of rows 
like image 116
Will Avatar answered Sep 22 '22 13:09

Will


Spyder within Anaconda (or R Studio for Python as I like to call it) gives you the ability to view and sort entire dataframes the same way you would in R using the variable explorer.

https://www.continuum.io/

enter image description here

like image 25
AffableAmbler Avatar answered Sep 22 '22 13:09

AffableAmbler