Skip to content

Instantly share code, notes, and snippets.

View Dhrumilcse's full-sized avatar

Dhrumil Patel Dhrumilcse

View GitHub Profile
# Bar chart
def plot_data(data):
data['Count'] = 1
plot_data = data[['amount','currency','Count']]
plot_data = plot_data.groupby(["currency"],as_index=False).Count.sum()
with chart_output:
print("Total data: ", len(data))
plot_bar(plot_data, x="currency", y="Count", color="currency")
def filter_data(data):
# Creating Dropdowns and buttons
dropdown_currency = widgets.Dropdown(options=data.currency.unique(), description='Currency:')
# Event handler for dropdowns
def dropdown_currency_eventhandler(change):
common_filtering(data, change.new)
#Call
# Only keep transactions where amount is < 1000
data = data[data.amount < 1000]
with data_process_output:
print(f"Processed a total of {len(data)} transactions.")
# Load existing vectorizer/model to make predictions
count_vectorizer = joblib.load("../supplementary/count_vectorizer")
data_ = data["Message"].tolist()
x_test = count_vectorizer.transform(data_)
model = joblib.load("../supplementary/game_classifier")
y_predicted = model.predict(x_test)
with data_process_output:
print(f"Predicted total {len(y_predicted)} values... Done.")
# Upload file and Upload button
upload_btn_output = widgets.Output()
display(upload_btn_output)
#Event handler for upload button
def upload_btn_eventhandler(obj):
#Clear output before each run
with data_process_output:
clear_output()
#Read file
for file_name in upload_file.value:
# Imports
import ipywidgets as widgets
# Buttons
upload_file = widgets.FileUpload(multiple=False)
upload_btn = widgets.Button(description="Upload and Predict", icon='check', button_style='success')
upload_btn.on_click(upload_btn_eventhandler)
input_widgets = widgets.HBox([upload_file, upload_btn])
with upload_btn_output:
display(input_widgets)
#Import Library
import folium
import pandas as pd
from folium.plugins import MarkerCluster
#Load Data
data = pd.read_excel("tesla-supercharger-france.xlsx")
latitude = data['Ylatitude']
longitude = data['Xlongitude']
station = data['n_station']
@Dhrumilcse
Dhrumilcse / tesla5.py
Last active September 22, 2019 21:13
#Import Library
import folium
import pandas as pd
#Load Data
data = pd.read_excel("tesla-supercharger-france.xlsx")
latitude = data['Ylatitude']
longitude = data['Xlongitude']
station = data['ad_station']
@Dhrumilcse
Dhrumilcse / tesla4.py
Last active September 22, 2019 21:19
#Import Library
import folium
import pandas as pd
#Load Data
data = pd.read_excel("tesla-supercharger-france.xlsx")
latitude = data['Ylatitude']
longitude = data['Xlongitude']
station = data['ad_station']