-
Notifications
You must be signed in to change notification settings - Fork 23
/
bamboolib_example.py
70 lines (44 loc) · 1.73 KB
/
bamboolib_example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# Databricks notebook source
# MAGIC %md
# MAGIC Please keep in mind that this require an installation on a cluster. then you will not be able to run it unless you have those permissions.
# COMMAND ----------
!pip install bamboolib==1.30.17
# COMMAND ----------
import bamboolib as bam
# COMMAND ----------
bam
# COMMAND ----------
# MAGIC %md
# MAGIC ### Code purely generated by Bamboolib
# COMMAND ----------
import plotly.express as px
fig = px.scatter(df, x='order_date', y='total_profit', size='units_sold', color='sales_channel')
fig
# COMMAND ----------
import plotly.express as px
fig = px.scatter(df, x='order_date', y='total_profit', size='unit_price', color='sales_channel')
fig
# COMMAND ----------
import plotly.express as px
fig = px.scatter(df, x='order_date', y='total_profit', size='units_sold', color='sales_channel', facet_row='order_prio')
fig
# COMMAND ----------
import plotly.express as px
fig = px.histogram(df, x='total_revenue')
fig
# COMMAND ----------
import pandas as pd; import numpy as np
df = pd.read_csv(bam.sales_csv)
# Step: Change data type of item_type to String/Text
df['item_type'] = df['item_type'].astype('string')
# Step: Change data type of country to String/Text
df['country'] = df['country'].astype('string')
# Step: Change data type of region to String/Text
df['region'] = df['region'].astype('string')
# Step: Change data type of sales_channel to String/Text
df['sales_channel'] = df['sales_channel'].astype('string')
# Step: Change data type of order_date to Datetime
df['order_date'] = pd.to_datetime(df['order_date'], infer_datetime_format=True)
# Step: Change data type of ship_date to Datetime
df['ship_date'] = pd.to_datetime(df['ship_date'], infer_datetime_format=True)
# COMMAND ----------