<jupyter_start><jupyter_text>Function Application and Mapping<jupyter_code>import pandas as pd
import numpy as np
data = pd.read_csv("train.csv")
data.head()
data.columns
data[(data['Age']>50) & (data["Sex"]=="female")].count()
data.describe()
data["Ticket"][data['Name']=="Allen, Mr. <NAME>"]
data["Ticket"][data["Parch"]==1]
frame = pd.DataFrame(np.random.randn(4, 3), columns=list('bde'),
                        index=['Utah', 'Ohio', 'Texas', 'Oregon'])
frame
frame.max(axis=1)
frame.min()
np.abs(frame)
f = lambda x: x.max() - x.min()
frame.apply(f)
f = lambda x: x**2
frame.apply(f)<jupyter_output><empty_output><jupyter_text>Sorting and Ranking<jupyter_code>obj = pd.Series(range(4), index=['d', 'a', 'b', 'c'])
obj
obj.sort_index(ascending=False)
frame = pd.DataFrame(np.arange(8).reshape((2, 4)),
                      index=['three', 'one'],
                         columns=['d', 'a', 'b', 'c'])
frame
frame.sort_index()
frame.sort_index(axis=1)
frame
frame1 = pd.DataFrame(np.arange(12,0,-1).reshape((3, 4)),
                      index=['three', 'one','four'],
                         columns=['d', 'a', 'b', 'c'])
frame1
frame1.sort_values(by=['a','b'])
data = pd.read_csv('data.csv')
data
data.sort_values(by='Best of Quizzes')
data.sort_values(by=['Best of Quizzes','Student Name'])
data
pd.options.display.max_rows = 10
obj = pd.Series([7, -5, 7, 4, 2, 0, 4, 7, 7,60])
obj
obj.sort_values(inplace=True)
obj
obj.rank(method='first')
obj.rank()
pd.options.display.max_rows=None

data
arr = np.array([3,5,100,6,7,2,9])
#np.max(arr)
print(f"The max value is {arr.max()}")
print()
print(f"The index of max value is {arr.argmax()}")
      
#np.min(arr)
arr.min()
data['Mid'].max()
data['Mid'].idxmax()<jupyter_output><empty_output><jupyter_text>Correlation and Covariance<jupyter_code>import pandas_datareader.data as web<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.2113733905579399, 'fraction_numerical': 0.023068669527896997, 'mean_word_length': 4.720858895705521, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 15, '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': '416550', 'license': 'MIT', 'n_tokens_mistral': 761, 'n_tokens_neox': 727, 'n_words': 133, 'path': 'Q2/important mix/Pandas Function Application and Mapping.ipynb', 'repo_name': 'qasim1020/PIAIC-Artificial-Intelligence', 'size': '1871'}