Last active
March 7, 2022 00:50
-
-
Save audhiaprilliant/1be30824161fdaec3afe25e264ac2635 to your computer and use it in GitHub Desktop.
Introduction to Plotly
This file contains hidden or 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
| # Data manipulation | |
| import pandas as pd | |
| # Mathematical operation | |
| import numpy as np | |
| # Data viz | |
| import plotly | |
| import plotly.graph_objects as go | |
| from plotly.subplots import make_subplots | |
| # Data set in list of JSON | |
| data = [ | |
| { | |
| 'Fruit': 'Apples', | |
| 'Sales': 15750 | |
| }, | |
| { | |
| 'Fruit': 'Avocados', | |
| 'Sales': 10000 | |
| }, | |
| { | |
| 'Fruit': 'Bananas', | |
| 'Sales': 25750 | |
| }, | |
| { | |
| 'Fruit': 'Blueberries', | |
| 'Sales': 10750 | |
| }, | |
| { | |
| 'Fruit': 'Grapes', | |
| 'Sales': 13750 | |
| }, | |
| { | |
| 'Fruit': 'Lemons', | |
| 'Sales': 10750 | |
| }, | |
| { | |
| 'Fruit': 'Oranges', | |
| 'Sales': 12750 | |
| }, | |
| { | |
| 'Fruit': 'Peaches', | |
| 'Sales': 10250 | |
| }, | |
| { | |
| 'Fruit': 'Strawberries', | |
| 'Sales': 14500 | |
| }, | |
| { | |
| 'Fruit': 'Watermelon', | |
| 'Sales': 12000 | |
| } | |
| ] | |
| # Convert list of JSON into data frame | |
| df = pd.DataFrame(data) | |
| # Show the dimension of data | |
| print('Dimension of data: {row} rows and {column} columns'.format( | |
| row = len(df), | |
| column = len(df.columns) | |
| ) | |
| ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment