Show Menu
Cheatography

Series Cheat Sheet (DRAFT) by

Tell about different commands availble for series

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Creating a Pandas Series

Convert an array to a Series in pandas.
data = np.arr­ay(­[1,­2,3­,4,­5,6]) num_ar­r_s­eries = pd.Ser­ies­(data)
Convert a list to a Series in pandas.
data = [25, 50, 75, 100] first_­series = pd.Ser­ies­(data)
Convert a dictionary to a Series in pandas.
first_dict = { "­nam­e1": "­Par­as", "­nam­e2": "­Luk­e", "­nam­e3": "­Sam­" } dict_s­eries = pd.Ser­ies­(fi­rst­_dict)

Aggreg­ation Methods

.sum ()
: Returns the result of adding all values in a Series together. .product: Returns the result of multip­lying all values in a Series.
.min()
Finds the smallest number in a Series.
.max()
Finds the largest number in a Series.
.median()
Returns the midpoint in a numerical data set.
.mean ()
Calculates the average value by adding all values and dividing by the total rows.
building an analytical picture of your numerical data set for deeper insights
 

Sort Methods

series.so­rt_­ind­ex(­inplace = True)
.sort_­index() with the parameter inplace. The default behavior for this method is to return a new copy of the Series.
series.so­rt_­val­ues­(as­cending = False, inplace = True)
.sort_­val­ues() will provide numerical and/or alphab­etical order in the output.

Display Methods

series.head()
captures the top rows of the Series:
series.tail()
captures the bottom rows of the Series:
 

Null Value Methods

.dropna()
method to remove — or drop — any null values, including NaNs
.fillna()
method to overwrite — or fill — null values
Best for: removing null values to improve the data integrity of your Series

Index Methods

series.il­oc[n]
use .iloc[] to call the value at index n+1
series.il­oc[0:n]
Slicing specifies a range of rows to return
series.lo­c["i­npu­t"]
.loc[] retrieves the row matching this string in the input