This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gradio as gr | |
from openai import OpenAI | |
import docx2txt | |
import PyPDF2 | |
api_key = "sk-" # Replace with your key | |
def read_text_from_file(file_path): | |
# Check the file type and read accordingly |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from bs4 import BeautifulSoup | |
import pandas as pd | |
def matchbymatch(id): | |
urlformat = 'https://stats.espncricinfo.com/ci/engine/player/{}.html?class=2;template=results;type=allround;view=match'.format(id) | |
page = requests.get(urlformat) | |
bs = BeautifulSoup(page.content, 'lxml') | |
rows = bs.find_all('tr',class_='data1') | |
data = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from io import BytesIO | |
import tarfile | |
import tempfile | |
from six.moves import urllib | |
from matplotlib import gridspec | |
from matplotlib import pyplot as plt | |
import numpy as np | |
from PIL import Image |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tensorflow as tf | |
import tensorflow_hub as hub | |
import matplotlib.pyplot as plt | |
import numpy as np | |
import PIL.Image | |
def load_img(path_to_img): | |
max_dim = 512 | |
img = tf.io.read_file(path_to_img) | |
img = tf.image.decode_image(img, channels=3) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import pandas | |
import json | |
import plotly.express as px | |
districts_daily = requests.get('https://api.covid19india.org/v4/timeseries.json') | |
districts_daily = districts_daily.text | |
districts_daily = json.loads(districts_daily) | |
dfs = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
active = [] | |
confirmed = [] | |
deaths = [] | |
deltaconfirmed = [] | |
deltadeaths = [] | |
deltarecovered = [] | |
recovered = [] | |
state = [] | |
for data in districts_daily['statewise']: | |
active.append(data['active']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import plotly.graph_objects as go | |
import requests | |
import pandas | |
import json | |
districts_daily = requests.get('https://api.covid19india.org/data.json') | |
districts_daily = districts_daily.text | |
districts_daily = json.loads(districts_daily) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import plotly.express as px | |
fig = px.line(df, x="date", y=["totalactive",'totalrecovered','totaldeceased'], | |
log_y= True, title='Total Coronavirus Cases in India') | |
fig.show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with open('Indian_States.txt') as f: | |
statejson = json.load(f) | |
fig = px.choropleth_mapbox(statedf, geojson=statejson, color="active", | |
locations="state", featureidkey="properties.NAME_1", | |
center={"lat": 23.2599, "lon": 77.4126}, | |
mapbox_style="carto-positron", zoom=3) | |
fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0}) | |
fig.show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
px.scatter(data2, x="totalconfirmed", y="totaldeceased", | |
animation_frame=data2.date.astype(str), animation_group="state", | |
size="totaltested", color="state", hover_name="state", | |
range_x=[0,450000], range_y=[0,16000] | |
) |