import pandas as pd
import numpy as np
!pip install openpyxl
arr = np.random.randint(low = 10, high = 100, size = (20, 10))
df = pd.DataFrame(data = arr)
df.shape
print(pd.ExcelWriter.__doc__)
with pd.ExcelWriter('myexcel.xlsx') as writer:
df.to_excel(writer)
print(pd.DataFrame.__doc__)
classes = np.tile(['good', 'bad', 'neutral'], 100)[:20]
classes = classes[np.random.randint(low = 0, high = 20, size = 20)]
df['Classes'] = classes
df.head()
df['Classes'], _ = pd.factorize(df['Classes'])
df.head()
df_2 = df.copy()[:15]
df.shape
df_2.shape
### Concatenation of dataframes
pd.concat(objs =[df, df_2.sort_index(ascending = False)], axis = 1)
angles = np.array([90, 180, 270, 360])
angles = np.deg2rad(angles)
vector = np.random.randint(low = 10, high = 100, size = (10))
vsum = np.sqrt(np.sum(vector**2))
vsum
vsum*vsum/np.dot(vector, vector)
np.cos(angles)
### Merge dataframes
pd.merge(left = df, right = df_2, how = 'outer')
all(['', 'dsfbujdfbvklfnbvk'])
any(df)
try_df = pd.concat(objs =[df, df_2.sort_index(ascending = False)], axis = 1)
all(try_df)
pd.isna(try_df)
try_df[pd.isna(try_df)]
try_df.fillna(value = 'Missing', inplace = True)
try_df
all(try_df)
pd.isna(try_df).sum()