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
| #Use plotly to visualize the network graph created using NetworkX | |
| #Adding edges to plotly scatter plot and specify mode='lines' | |
| edge_trace = go.Scatter( | |
| x=[], | |
| y=[], | |
| line=dict(width=1,color='#888'), | |
| hoverinfo='none', | |
| mode='lines') | |
| for edge in G.edges(): |
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
| #Create the network graph using networkx | |
| if uploaded_file is not None: | |
| df=pd.read_csv(uploaded_file) | |
| A = list(df["Source"].unique()) | |
| B = list(df["Target"].unique()) | |
| node_list = set(A+B) | |
| G = nx.Graph() #Use the Graph API to create an empty network graph object | |
| #Add nodes and edges to the graph object | |
| for i in node_list: |
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
| import base64 | |
| def add_bg_from_local(image_file): | |
| with open(image_file, "rb") as image_file: | |
| encoded_string = base64.b64encode(image_file.read()) | |
| st.markdown( | |
| f""" | |
| <style> | |
| .stApp {{ | |
| background-image: url(data:image/{"png"};base64,{encoded_string.decode()}); | |
| background-size: cover |
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
| def add_bg_from_url(): | |
| st.markdown( | |
| f""" | |
| <style> | |
| .stApp {{ | |
| background-image: url("https://cdn.pixabay.com/photo/2019/04/24/11/27/flowers-4151900_960_720.jpg"); | |
| background-attachment: fixed; | |
| background-size: cover | |
| }} | |
| </style> |
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
| fig.update_layout( | |
| title='Project Plan Gantt Chart', | |
| bargap=0.1, | |
| width=850, | |
| height=500, | |
| xaxis_title="", | |
| yaxis_title="", | |
| title_x=0.5, | |
| legend_title="", | |
| legend = dict(orientation = 'v', xanchor = "center", x = 0.92, y= 0.98), #Adjust legend position |
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
| colors = {} | |
| colors['Planned'] = 'rgb(29, 133, 60)' #specify the color for the 'planned' schedule bars | |
| colors['Actual'] = 'rgb(245, 148, 22)' #specify the color for the 'actual' schedule bars | |
| fig = px.timeline( | |
| df, | |
| x_start="Start", | |
| x_end="Finish", | |
| y="Task", | |
| color='Duration Type', |
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
| import pandas as pd | |
| import numpy as np | |
| import plotly.express as px | |
| df=pd.read_csv(r'C:\Users\13525\Desktop\Insights Bees\Gantt_chart_multi_layer\Data\project_plan.csv') | |
| df['Start'] = df['Start'].astype('datetime64') | |
| df['Finish'] = df['Finish'].astype('datetime64') |
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
| year_list=list(df_wide.columns) | |
| df_long = pd.melt(df_wide, value_vars=year_list,value_name='Avg. Price ($)', ignore_index=False) |
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
| df_wide=pd.pivot(df, index=['Series ID','Item'], columns = 'Year Month',values = 'Avg. Price ($)') #Reshape from long to wide | |
| #Re-arange the new columns in the correct order | |
| cols = df['Year Month'].unique() | |
| df_wide=df_wide[cols] |
NewerOlder