Skip to content

Instantly share code, notes, and snippets.

View pranjalAI's full-sized avatar

Pranjal Saxena pranjalAI

View GitHub Profile
from collections import Counter
mylst = [1,1,1,2,2,2,2,3,3,3,3,3,4,4,5,6,6,6]
print(Counter(mylst))
Total_transactions = len(data)
normal = len(data[data.Class == 0])
fraudulent = len(data[data.Class == 1])
fraud_percentage = round(fraudulent/normal*100, 2)
print(cl('Total number of Trnsactions are {}'.format(Total_transactions), attrs = ['bold']))
print(cl('Number of Normal Transactions are {}'.format(normal), attrs = ['bold']))
print(cl('Number of fraudulent Transactions are {}'.format(fraudulent), attrs = ['bold']))
print(cl('Percentage of fraud Transactions is {}'.format(fraud_percentage), attrs = ['bold']))
#Packages related to general operating system & warnings
import os
import warnings
warnings.filterwarnings('ignore')
#Packages related to data importing, manipulation, exploratory data #analysis, data understanding
import numpy as np
import pandas as pd
from pandas import Series, DataFrame
from termcolor import colored as cl # text customization
#Packages related to data visualizaiton
import mahotas
import mahotas.demos
import numpy as np
from pylab import imshow, gray, show
from os import path
photo = mahotas.demos.load('luispedro', as_grey=True)
photo = photo.astype(np.uint8)
gray()
imshow(photo)
show()
resp = ur.urlopen("https://thumbor.forbes.com/thumbor/960x0/https%3A%2F%2Fspecials-images.forbesimg.com%2Fdam%2Fimageserve%2F1068867780%2F960x0.jpg%3Ffit%3Dscale")
image = np.asarray(bytearray(resp.read()), dtype="uint8")
im = cv2.imdecode(image, cv2.IMREAD_COLOR)
blur = cv2.GaussianBlur(im, (5,5),0)
cv2_imshow(blur)
html_doc = """
<html>
<head>
<title>Test Page</title>
</head>
<body>
<p><b>This is a test page.</b></p>
</body>
</html>
"""
import yara
rule = yara.compile(source='rule foo: bar {strings: $a = "lmn" condition: $a}')
matches = rule.match(data='abcdefgjiklmnoprstuvwxyz')
import pandas as pd
import missingno as msno
dataset = pd.read_csv('filename.csv')
msno.bar(dataset)
import altair as alt
from vega_datasets import data
iris = data.iris()
# Making the Scatter Plot with altair
alt.Chart(iris).mark_point().encode(
# defining x-axis
x='sepalLength',
# defining y-axis
y='petalLength',
import plotly.graph_objects as go
fig = go.figure(data = go.bar(y=[1,2,3]))
fig.show()