Cheatography
https://cheatography.com
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.array([1,2,3,4,5,6]) num_arr_series = pd.Series(data) |
Convert a list to a Series in pandas. |
data = [25, 50, 75, 100] first_series = pd.Series(data) |
Convert a dictionary to a Series in pandas. |
first_dict = { "name1": "Paras", "name2": "Luke", "name3": "Sam" } dict_series = pd.Series(first_dict) |
Aggregation Methods
.sum () |
: Returns the result of adding all values in a Series together. .product: Returns the result of multiplying 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.sort_index(inplace = True) |
.sort_index() with the parameter inplace. The default behavior for this method is to return a new copy of the Series. |
series.sort_values(ascending = False, inplace = True) |
.sort_values() will provide numerical and/or alphabetical 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.iloc[n] |
use .iloc[] to call the value at index n+1 |
series.iloc[0:n] |
Slicing specifies a range of rows to return |
series.loc["input"] |
.loc[] retrieves the row matching this string in the input |
|