Posts

Showing posts from March, 2023

Plotly Bar Chart

 Coming from an analyst background, I have been making bar charts for years.  So, this example is not very interesting.  However, it shows the simplicity of plotly express and how easily one can create a bar graph.  I didn’t stray far from the path regarding the official plotly example.  It is their example.  However, I wanted to show how easy it is to get going.  The only thing I modified was the graphic size in Google Colab.  Very easy and approachable! import plotly.express as px long_df = px . data . medals_long () fig.update_layout( width=800, #set the width of the plot to 800 pixels height=500, #set the height of the plot to 500 pixels ) fig = px . bar ( long_df , x = "nation" , y = "count" , color = "medal" , title = "Long-Form Input" ) fig . show ( fig = px.bar(filtered_df, x="nation", y="count", color="medal", title="Long-Form Input") fig.show() The full example is located at:...

Plotly Adventure

My goal is to learn new packages related to visualizations and dashboarding with python.  An overwhelming vote by the internet says, "learn plotly!" As a result, I asked GPT-4, what are things to know about plotly, and this is the response. I plan to follow each section and provide a post diving into each topic.  As an experienced programmer with years of experience with Plotly, I would guide you through the main principles and learning steps as follows: Introduction to Plotly : Plotly is an open-source graphing library that makes it easy to create interactive, publication-quality visualizations in Python, R, and other programming languages. It provides a high-level interface for drawing attractive and informative statistical graphics. Understanding Plotly components : Familiarize yourself with the core components of Plotly, such as Plotly Express (a high-level interface for creating common chart types quickly) and Graph Objects (a low-level interface for more customizable ch...

North Carolina University List

Image
  I needed a list of public universities in North Carolina. What does anyone do? Start Googling. The first return was a Wikipedia page. I clicked on it and saw this beautiful table with all the information I wanted. Then I remembered there is a great method in python and pandas to pull tables from websites very easily. All I need to do is use read_html and sort the data after that. Below is a short description for each step. This code uses the Python programming language and the pandas library to read a table from a Wikipedia page about colleges and universities in North Carolina. The code begins by importing the pandas library and assigning the URL of the Wikipedia page to a variable called URL. Next, the pd.read_html() function is used to read the HTML table from the URL and return a list of tables. The first table in the list is selected using tables[0] and assigned to a new variable called df. The .query() method is then used to filter the rows of the DataFram...

Report Lab Introduction

During the past weekend, my task involved developing a report using Excel. This report, ultimately converted into a PDF, encompassed three tables, footnotes, titles, and graphics. The fulfillment of this task involved liaising with various individuals who furnished me with a summary of financial report data. I proceeded to transfer this data into an Excel spreadsheet to generate the report. While the entire operation was simple and direct, my interest was piqued to explore a new Python package. After some initial exploration, I chose to delve into the world of reportlab. Reportlab is a Python library utilizing an x and y coordinate-based layout system. Essentially, this implies that the page layout is dictated by points, with one inch containing 72 points. The page's bottom-left corner is demarcated as x = 0 and y = 0. If one desires to insert an item halfway up an 8.5 by 11-inch page, x = 612 / 2 or x=305 can be used. Furthermore, it provides a float-based system, which proves mor...