<jupyter_start><jupyter_text><jupyter_code>import pandas as pd
url="https://raw.githubusercontent.com/ChiranjeebDash/ChiranjeebDash_18cse052/main/menu.csv"
df=pd.read_csv(url)
df
df.head()
df.tail()
import numpy as np
x = np.eye(5,dtype=int)
print("x =\n",x)
import numpy as np
a = [[1, 2], [3, 4]]
x = np.array(a)
print("list to array:\n",x)
a2 = x.tolist()
print("array to list:\n",a2)
print(a == a2)
import numpy as np
N=int(input())# not more than N inputs will be considered
fvalues=list(map(float, input().split(' ')[:N]))
F = np.array(fvalues)
print("Values in Fahrenheit degrees:")
print(F)
print("Values in  Centigrade degrees:") 
print(5*F/9 - 5*32/9)
import numpy as np
from numpy import linalg as la  
R = int(input("Enter the number of rows:")) 
C = int(input("Enter the number of columns:"))   

if R==C:
  print("Enter the entries in a single line (separated by space): ") 
  entries = list(map(int, input().split()))   
  matrix = np.array(entries).reshape(R, C) 
  print("Original ",R,"x",C,"-D matrix")
  print(matrix)
  print("Determinant of the said ",R,"x",C,"-D matrix")
  print(np.linalg.det(matrix))
else:
  print("Invalid Dimensional Array Input")
import numpy as np
x = np.random.random((5,5))
print("Original Array:")
print(x) 
xmin, xmax = x.min(), x.max()
print("Minimum and Maximum Values:")
print(xmin, xmax)

import numpy as np
nums =  np.random.rand(15)
print("Original array:")
print(nums)
print("\nSorted first 5 elements:")
print(nums[np.argpartition(nums,range(8))])
import numpy as np
x = np.array([[1,2,3], [4,5,6]])
print("Original array: ")
print(x)
print("Cumulative sum of the elements along a given axis:")
r = np.cumsum(x)
print(r)
print("\nSum over rows for each of the 3 columns:")
r = np.cumsum(x,axis=0) 
print(r)
print("\nSum over columns for each of the 2 rows:")
r = np.cumsum(x,axis=1) 
print(r)

import numpy as np
yesterday = np.datetime64('today', 'D') - np.timedelta64(1, 'D')
print("Yestraday: ",yesterday)
today     = np.datetime64('today', 'D')
print("Today: ",today)
tomorrow  = np.datetime64('today', 'D') + np.timedelta64(1, 'D')
print("Tomorrow: ",tomorrow)
import numpy as np
x = np.array([' python exercises ', ' PHP  ', ' java  ', '  C++'], dtype=np.str)
print("Original Array:")
print(x)
stripped = np.char.strip(x)
print("\nRemove the leading and trailing whitespaces: ", stripped)
import numpy as np
a=np.array([(1,2,3),(4,5,6)])
print(a)
import pandas as pd
df = pd.DataFrame({'X':[78,85,96,80,86], 'Y':[84,94,89,83,86],'Z':[86,97,96,72,83]});
print(df)
import pandas as pd
s = pd.Series([2, 4, 6, 8, 10])
print(s)
import pandas as pd
ds1 = pd.Series([2, 4, 6, 8, 10])
ds2 = pd.Series([1, 3, 5, 7, 9])
ds = ds1 + ds2
print("Add two Series:")
print(ds)
print("Subtract two Series:")
ds = ds1 - ds2
print(ds)
print("Multiply two Series:")
ds = ds1 * ds2
print(ds)
print("Divide Series1 by Series2:")
ds = ds1 / ds2
print(ds)
import pandas as pd
import numpy as np
exam_data = [{'name':'Anastasia', 'score':12.5}, {'name':'Dima','score':9}, {'name':'Katherine','score':16.5}]
df = pd.DataFrame(exam_data)
for index, row in df.iterrows():
    print(row['name'], row['score'])
import pandas as pd
df1 = pd.DataFrame({'A': [None, 0, None], 'B': [3, 4, 5]})
df2 = pd.DataFrame({'A': [1, 1, 3], 'B': [3, None, 3]})
df1.combine_first(df2)
print("Original DataFrames:")
print(df1)
print("--------------------")
print(df2)
print("\nMerge two dataframes with different columns:")
result = df1.combine_first(df2)
print(result)
import datetime
from datetime import datetime
print("Datetime object for Jan 11 2012:")
print(datetime(2012, 1, 11))
print("\nSpecific date and time of 9:20 pm") 
print(datetime(2011, 1, 11, 21, 20))
print("\nLocal date and time:")
print(datetime.now())
print("\nA date without time: ")
print(datetime.date(datetime(2012, 5, 22)))
print("\nCurrent date:")
print(datetime.now().date())
print("\nTime from a datetime:")
print(datetime.time(datetime(2012, 12, 15, 18, 12)))
print("\nCurrent local time:") 
print(datetime.now().time())

import pandas as pd
pd.set_option('display.max_rows', None)
#pd.set_option('display.max_columns', None)
df = pd.DataFrame({
'ord_no':[70001,70009,70002,70004,70007,70005,70008,70010,70003,70012,70011,70013],
'purch_amt':[150.5,270.65,65.26,110.5,948.5,2400.6,5760,1983.43,2480.4,250.45, 75.29,3045.6],
'ord_date': ['2012-10-05','2012-09-10','2012-10-05','2012-08-17','2012-09-10','2012-07-27','2012-09-10','2012-10-10','2012-10-10','2012-06-27','2012-08-17','2012-04-25'],
'customer_id':[3005,3001,3002,3009,3005,3007,3002,3004,3009,3008,3003,3002],
'salesman_id': [5002,5005,5001,5003,5002,5001,5001,5004,5003,5002,5004,5001]})
print("Original Orders DataFrame:")
print(df)
print("\nGroupby to find first order date for each group(salesman_id):")
result = df.groupby('salesman_id')['ord_date'].min()
print(result)

import pandas as pd
import numpy as np
np.random.seed(24)
df = pd.DataFrame({'A': np.linspace(1, 10, 10)})
df = pd.concat([df, pd.DataFrame(np.random.randn(10, 4), columns=list('BCDE'))],
               axis=1)
df.iloc[0, 2] = np.nan
df.iloc[3, 3] = np.nan
df.iloc[4, 1] = np.nan
df.iloc[9, 4] = np.nan
print("Original array:")
print(df)
print("\nBar charts in dataframe:")
df.style.bar(subset=['B', 'C'], color='#d65f5f')
import pandas as pd
df = pd.DataFrame({
    'school_code': ['s001','s002','s003','s001','s002','s004'],
    'class': ['V', 'V', 'VI', 'VI', 'V', 'VI'],
    'name': ['<NAME>','<NAME>','<NAME>', '<NAME>', '<NAME>', '<NAME>'],
    'date_of_birth': ['15/05/2002','17/05/2002','16/02/1999','25/09/1998','11/05/2002','15/09/1997'],
    'weight': [35, 37, 33, 30, 31, 32]})
     
print("Original DataFrame:")
print(df)
print("\nDefault Index Range:")
print(df.index)
df.index += 10 
print("\nNew Index Range:")
print(df.index)
print("\nDataFrame with new index:")
print(df)
import pandas as pd
import re as re
pd.set_option('display.max_columns', 10)
df = pd.DataFrame({
    'company_code': ['c0001','c0002','c0003', 'c0003', 'c0004'],
    'company_phone_no': ['Company1-Phone no. 4695168357','Company2-Phone no. 8088729013','Company3-Phone no. 6204658086', 'Company4-Phone no. 5159530096', 'Company5-Phone no. 9037952371']
    })
print("Original DataFrame:")
print(df)
def find_phone_number(text):
    ph_no = re.findall(r"\b\d{10}\b",text)
    return "".join(ph_no)
df['number']=df['company_phone_no'].apply(lambda x: find_phone_number(x))
print("\Extracting numbers from dataframe columns:")
print(df)<jupyter_output>Original DataFrame:
  company_code               company_phone_no
0        c0001  Company1-Phone no. 4695168357
1        c0002  Company2-Phone no. 8088729013
2        c0003  Company3-Phone no. 6204658086
3        c0003  Company4-Phone no. 5159530096
4        c0004  Company5-Phone no. 9037952371
\Extracting numbers from dataframe columns:
  company_code               company_phone_no      number
0        c0001  Company1-Phone no. 4695168357  4695168357
1        c0002  Company2-Phone no. 8088729013  8088729013
2        c0003  Company3-Phone no. 6204658086  6204658086
3        c0003  Company4-Phone no. 5159530096  5159530096
4        c0004  Company5-Phone no. 9037952371  9037952371
{'fraction_non_alphanumeric': 0.19435517675003494, 'fraction_numerical': 0.1229565460388431, 'mean_word_length': 4.979949874686716, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '47402', 'license': 'Apache-2.0', 'n_tokens_mistral': 3329, 'n_tokens_neox': 2758, 'n_words': 670, 'path': 'DMDWass2.ipynb', 'repo_name': 'ChiranjeebDash/ChiranjeebDash_18cse052', 'size': '7194'}