Skip to content

Instantly share code, notes, and snippets.

View hashABCD's full-sized avatar
🖖

Abhijith Chandradas hashABCD

🖖
View GitHub Profile
@hashABCD
hashABCD / Extract Metadata
Created March 12, 2022 00:52
Extract Metadata using python
# Import Libraries
from PIL import Image
from PIL.ExifTags import TAGS
# Open Image
img=Image.open('img.jpg')
#Get EXIF Data
exif_table={}
for k, v in img.getexif().items():
@hashABCD
hashABCD / photo2pixelart
Created August 26, 2021 02:35
Function which converts photo into pixel art
def photo2pixelart(image, i_size, o_size):
"""
image: path to image file
i_size: size of the small image eg:(8,8)
o_size: output size eg:(10000,10000)
"""
#read file
img=Image.open(image)
#convert to small image
@hashABCD
hashABCD / img2sketch
Created July 29, 2021 12:40
Function to convert image to sketch
def img2sketch(photo, k_size):
#Read Image
img=cv2.imread(photo)
# Convert to Grey Image
grey_img=cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
# Invert Image
invert_img=cv2.bitwise_not(grey_img)
#invert_img=255-grey_img
@hashABCD
hashABCD / yf_balance_sheet
Created March 25, 2021 11:09
yf_balance_sheet
import yfinance as yf
aapl=yf.Ticker('aapl')
aapl.quarterly_balance_sheet
#aapl.balancesheet
@hashABCD
hashABCD / matplotlib_style_iterator
Created March 25, 2021 10:42
matplotlib_style_iterator
import matplotlib.pyplot as plt
a=[1,2,3,4]
b=[4,8,7,3]
def plotter(s):
plt.figure()
plt.style.use(s)
plt.plot(a,b)
plt.title(s)
plt.show()
@hashABCD
hashABCD / quadrant analysis
Last active February 3, 2021 17:13
Quadrant Analysis
plt.figure(figsize=(12,8))
#Scatterplot
sns.scatterplot(data=hdi_df, x='gni_pc', y='life_ex')
#Title
plt.title(f"G 20 Countries : {abbr['gni_pc']} vs {abbr['life_ex']}")
# x and y axis labels
plt.xlabel(abbr['gni_pc'])
@hashABCD
hashABCD / Dictionary-create
Created November 7, 2020 11:05
create dictionary
currancy_dict={'USD':'Dollar',
'EUR':'Euro',
'GBP':'Pound',
'INR':'Rupee'}
@hashABCD
hashABCD / preprocess
Created October 26, 2020 14:43
preprocess covid data for flourish
df_conf.drop(['Province/State','Lat', 'Long'],axis=1, inplace=True)
df_c=pd.DataFrame(columns=df_conf.columns)
df_c['Country/Region']=country_list
for col_name in df_c.keys()[1:]:
for ctry in country_list:
x=df_conf[col_name][df_conf["Country/Region"]==ctry].sum()
df_c[col_name][df_c['Country/Region']==ctry]=x