Pandas commands ending with parentheses and those that do not
This introduction to pandas is derived from Data School's pandas Q&A with my own notes and code.
Pandas commands ending with parentheses and those that do not¶
In [1]:
import pandas as pd
In [2]:
url = 'http://bit.ly/imdbratings'
movies = pd.read_csv(url)
In [4]:
# Looking at the first 5 rows of the DataFrame
movies.head()
Out[4]:
In [6]:
# This will show descriptive statistics of numeric columns
movies.describe()
Out[6]:
In [14]:
movies.describe(include=['float64'])
Out[14]:
In [7]:
# Finding out dimensionality of DataFrame
movies.shape
Out[7]:
In [9]:
# Finding out data types of each columns
movies.dtypes
Out[9]:
In [15]:
type(movies)
Out[15]:
As a Data Frame, it has certain methods and attributes
- Methods: with parentheses
- Action-oriented
- movies.head()
- movies.describe()
- Parentheses allows optional arguments
- movies.describe(include='object')
- Action-oriented
- Attributes: without parentheses
- Description-oriented
- movies.shape
- movies.dtypes
- Description-oriented
Hit shift + tab multiple times to learn more about the parantheses
- 1x for a pop-up
- 2x for a larger pop-up
- 4x for a split-screen