<jupyter_start><jupyter_text><jupyter_code>import numpy as np
import pandas as pd
 Object_DataFrame=pd.DataFrame([[1,3],[2,5],[np.nan,np.nan],[6,7]],index=['A','B','C','D'],columns=[1,2])
Object_DataFrame
#In order to do the sum of the columns
Object_DataFrame.sum()
#Doing sum on the rows
Object_DataFrame.sum(axis='columns')
Object_DataFrame.sum(axis=1)
# 'skipna' excludes the Nan values and it is true by default
Object_DataFrame.sum(axis=1,skipna=False)
d = {'num_legs': [4, 4, 2, 2],
     'num_wings': [0, 0, 2, 2],
     'class': ['mammal', 'mammal', 'mammal', 'bird'],
     'animal': ['cat', 'dog', 'bat', 'penguin'],
     'locomotion': ['walks', 'walks', 'flies', 'walks']}
df = pd.DataFrame(data=d)
df = df.set_index(['class', 'animal', 'locomotion'])
df
#count the number of NA values
Object_DataFrame.count()
#Compute the set of summary statistics of Series or each DataFrame column
Object_DataFrame.describe()
#Compute the minimum values
Object_DataFrame.min(axis=1)
Object_DataFrame.min()
#Compute the maximum values
Object_DataFrame.max()

sr = pd.Series([34, 5, 13, 32, 4, 15],index = ['A', 'B', 'C', 'D', 'E', 'F']) 
  
sr

#Compute the index location at which minimum value is obtained
sr.argmin()
#Compute the index location at which maximum value is obtained
sr.argmax()
#Computes the index labels at which maximum value is obtained
Object_DataFrame.idxmax()
Object_DataFrame.idxmax(axis=1)
#Computes the index labels at which minimum value is obtained
Object_DataFrame.idxmin(axis=1)
Object_DataFrame.idxmin()
#Computes the sample quantile ranging from 0 to 1
Object_DataFrame.quantile()
#Computes the sum of values
Object_DataFrame.sum()
Object_DataFrame.sum(axis=1,skipna=False)
#Compute the mean of the values
Object_DataFrame.mean()
Object_DataFrame.mean(axis=1)
#Compute the Arithmetic median of values
Object_DataFrame.median()
Object_DataFrame.median(axis=1)
#Compute the mean absolute deviation from mean value
Object_DataFrame.mad()
#Computes the product of all values
Object_DataFrame.prod()
Object_DataFrame.prod(axis=1)
#Computes the variance of values
Object_DataFrame.var()
Object_DataFrame.var(axis=1)
#Computes the standard deviation of values
Object_DataFrame.std()
Object_DataFrame.std(axis=1)
#Compute the skewness (third moment) of values
Object_DataFrame.skew()
Object_DataFrame.skew(axis=1)
#Compute the kurtosis (fourth moment) of values
Object_DataFrame.kurt()
Object_DataFrame.kurt(axis=1)
#Compute the cumulative sum 
Object_DataFrame.cumsum()
Object_DataFrame.cumsum(axis=1)
#Compute the cumulative minimum values
Object_DataFrame.cummin()
Object_DataFrame.cummin(axis=1)
#Compute the cumulative maximum values
Object_DataFrame.cummax()
Object_DataFrame.cummax(axis=1)
#Compute the cumulative product values
Object_DataFrame.cumprod()
Object_DataFrame.cumprod(axis=1)
#Computes the first arithmetic difference
Object_DataFrame.diff()
Object_DataFrame.diff(axis=1)
#Computes the percent change
Object_DataFrame.pct_change()
Object_DataFrame.pct_change(axis=1)<jupyter_output><empty_output><jupyter_text>Unique Values, Value Counts & Membership<jupyter_code>Object_Series=pd.Series(['Alek','Alek','ALEK','Datta','Datta'])
Object_Series
#Gives out the unique value in the series
Object_Series.unique()
#Sometimes using unique doesnot ensure that the values comes out in the ordered manner
#In order to sort the value we have to use .sort method
Unique=Object_Series.unique()
a=Unique.sort()
a
#Returns the series which contains the values as the index and the frquencies as it values, ordered count in descending order
Object_Series.value_counts()
#If we do not want the sort the output
pd.value_counts(Object_Series.values,sort=False)
# The method computes the boolean array indicating whether each Series value is contained in the passed sequence of values
Object_Series.isin(['ALEK','Hello'])
index = pd.Index(['c', 'a', 'b'])
index.get_indexer(['a', 'b', 'x'])<jupyter_output><empty_output><jupyter_text>Correlation and Covariance<jupyter_code>import pandas_datareader.data as dt
MainData={ticker:dt.get_data_yahoo(ticker) for ticker in ['AAPL','IBM','MSFT','GOOG'] }
MainData
Price=pd.DataFrame({ticker:data['Adj Close'] for ticker, data in MainData.items()})
Price
Volume=pd.DataFrame({ticker:data['Volume'] for ticker,data in MainData.items()})
Volume
Change_In_Price=Price.pct_change()
#Gives the percentage of the last rows
Change_In_Price.tail()
#Compute pairwise correlation of columns, excluding NA/null values. Returns the correlation between Apple and Google Column
Change_In_Price['AAPL'].corr(Change_In_Price['GOOG'])
#Compute pairwise covariance of columns, excluding NA/null values.
Change_In_Price['AAPL'].cov(Change_In_Price['GOOG'])
#Returns the full correlation as a DataFrame
Change_In_Price.corr()
#Returns the full covariance as a DataFrame
Change_In_Price.cov()
Change_In_Price.corrwith(Volume)
Change_In_Price.corrwith(Volume,axis=1)
Change_In_Price.corrwith(Change_In_Price.GOOG)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11664324432844811, 'fraction_numerical': 0.009636619152780567, 'mean_word_length': 7.4872231686541735, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '269364', 'license': 'MIT', 'n_tokens_mistral': 1679, 'n_tokens_neox': 1620, 'n_words': 467, 'path': 'Pandas_Tutorial_3.ipynb', 'repo_name': 'alekhaya99/Pandas_Tutorial', 'size': '4981'}