Skip to content

Instantly share code, notes, and snippets.

@8080labs
8080labs / plotly_rebinable_histogram.py
Last active March 29, 2022 20:51
plotly_rebinable_histogram
import plotly.graph_objs as go
import ipywidgets as widgets
def rebinnable_interactive_histogram(series, initial_bin_width=10):
figure_widget = go.FigureWidget(
data=[go.Histogram(x=series, xbins={"size": initial_bin_width})]
)
bin_slider = widgets.FloatSlider(
@zaloogarcia
zaloogarcia / pandas_to_spark.py
Last active April 19, 2022 16:20
Script for converting Pandas DF to Spark's DF
from pyspark.sql.types import *
# Auxiliar functions
# Pandas Types -> Sparks Types
def equivalent_type(f):
if f == 'datetime64[ns]': return DateType()
elif f == 'int64': return LongType()
elif f == 'int32': return IntegerType()
elif f == 'float64': return FloatType()
else: return StringType()