Skip to content

Instantly share code, notes, and snippets.

View rsalaza4's full-sized avatar
🎯
Focusing

Roberto Salazar rsalaza4

🎯
Focusing
View GitHub Profile
# Import required libraries
import pandas as pd
# Read csv file
df = pd.read_csv("medium_data.csv", index_col="id")
# Visualize data frame top rows
df.head()
# Create a title for the dashboard
title = pn.pane.Markdown(
"""
# Tesla Stock Analysis Dashboard
""",
width=1000,
)
# Create a welcome message for the dashboard
welcome = pn.pane.Markdown(
# Create an hvplot table for the stock data
TSLA_df_table = TSLA.hvplot.table(width=1000)
# Create an hvplot line plot for the closing price
TSLA_closing_price_plot = TSLA.drop(columns="Daily_Return").hvplot.line(title="TSLA Closing Price & Simple Moving Average", ylabel="USD", height=500, width=1000)
# Create an hvplot line plot for the daily return
TSLA_daily_retrun_plot = TSLA["Daily_Return"].hvplot.line(title="TSLA Daily Returns", ylabel="Daily Return", height=500, width=1000)
# Create an hvplot bar plot for the daily volume
# Select 'Close' column only
TSLA = TSLA_data[["Close"]].copy()
# Add a daily return column
TSLA["Daily_Return"] = TSLA["Close"].pct_change()
# Add a simple moving average column of window of 10 days
TSLA["SMA10"] = TSLA["Close"].rolling(window=10).mean()
# Add a simple moving average column of window of 50 days
# Import required libraries
import yfinance as yf
import pandas as pd
import hvplot.pandas
import panel as pn
pn.extension('plotly')
import plotly.express as px
import plotly.graph_objects as go
# Get stock data
# Import libraries and dependencies
import numpy as np
import pandas as pd
# ------------------------------ Data Set Loading ------------------------------
# Read data set
df = pd.read_csv('Desktop/file.csv')
# Visualize data set
# Import dependencies
import pandas as pd
import pyodbc
# Specify credentials
server = '<YOUR SERVER>'
database = '<YOUR DATABASE>'
username = '<YOUR USERNAME>'
password = '<YOUR PASSWORD>'
driver= '{ODBC Driver 17 for SQL Server}'
# Calculate Cp
Cp = (USL-LSL)/(6*np.std(data))
# Calculate Cpk
Cpk = min((USL-data.mean())/(3*data.std()), (data.mean()-LSL)/(3*data.std()))
# Calculate z-value
z = min((USL-data.mean())/(data.std()), (data.mean()-LSL)/(data.std()))
# Get data summary statistics
# Import required libraries
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
from scipy.stats import norm
# Set specification limits
target = 5
LSL = 3
PROCESS CAPABILITY ANALYSIS
-----------------------------------
Specifications
Taget: 5
LSL: 3
USL: 7
-----------------------------------
Indices