Skip to content

Instantly share code, notes, and snippets.

@amansingh9097
Created October 14, 2021 07:17
Show Gist options
  • Save amansingh9097/fa45b371f25f8888c391df583e8fc05b to your computer and use it in GitHub Desktop.
Save amansingh9097/fa45b371f25f8888c391df583e8fc05b to your computer and use it in GitHub Desktop.
Visualize your LinkedIn connections
#!/usr/bin/env python
# coding: utf-8
# author: https://github.com/amansingh9097/
import pandas as pd
import numpy as np
import plotly.express as px
# How to get your connection data?
# On LinkedIn, Go to "Me" --> "Settings & Privacy" --> "Get a Copy of your Data"
connections = pd.read_csv('Connections.csv')
connections = connections.loc[~connections['First Name'].isna()]
connections.loc[:, 'Company'] = connections.loc[:, 'Company'].fillna(value='Company: Unknown')
connections.loc[:, 'Position'] = connections.loc[:, 'Position'].fillna(value='Position: Unknown')
connections.loc[:, 'Email Address'] = connections.loc[:, 'Email Address'].fillna(value='eMail: Hidden')
connections.loc[:, 'Full Name'] = connections[['First Name','Last Name']].apply(lambda x: " ".join(x), axis=1)
# print(connections.head())
# All connections
fig = px.treemap(connections, path=[px.Constant("My LinkedIn Network: {} connections".format(len(connections))),
'Company', 'Position', 'Full Name'])
fig.update_traces(root_color="lightskyblue")
fig.update_layout(margin = dict(t=50, l=25, r=25, b=25))
fig.show()
# Top Positions from all connections
fig1 = px.treemap(connections, path=[px.Constant("My LinkedIn Network: {} Positions".format(len(connections['Position'].unique()))),
'Position'])
fig1.update_traces(root_color="skyblue")
fig1.update_layout(margin = dict(t=50, l=25, r=25, b=25))
fig1.show()
# Current Role ---> #ToDO: change to your role specific position keywords
df = connections.loc[connections['Position'].str.contains('Data Scien')]
fig = px.treemap(df, path=[px.Constant("My Data-Scientist Network: {}".format(len(df))), 'Position', 'Company', 'Full Name'])
fig.update_traces(root_color="lightskyblue")
fig.update_layout(margin = dict(t=50, l=25, r=25, b=25))
fig.show()
# Past Orgs ---> #ToDo: change to your orgs
df = connections.loc[connections['Company'].isin(['Clover Infotech','IBM','Tata Consultancy Services',
'3LOQ','Sunera Technologies','Amazon'])]
fig = px.treemap(df, path=[px.Constant("Connections from Orgs where I have worked in past: {}".format(len(df))),
'Company', 'Position', 'Full Name'])
fig.update_traces(root_color="lightskyblue")
fig.update_layout(margin = dict(t=50, l=25, r=25, b=25))
fig.show()
# Leadership Roles
df = connections.loc[connections['Position'].str.contains('Founder|VP|CTO|CEO|COO|CFO|SVP|AVP|Director|Head of|Vice|President')]
fig = px.treemap(df, path=[px.Constant("Leaders/Founders/CEO/CTO/VP/AVP etc: {}".format(len(df))),
'Company','Position','Full Name'])
fig.update_traces(root_color="lightskyblue")
fig.update_layout(margin = dict(t=50, l=25, r=25, b=25))
fig.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment