我有数据显示每个员工与其经理的关系(人:经理)-
data = {'PersonX':'Person1', 'PersonY':'Person1', 'PersonZ':'Person 2', 'Person1':'Person100','Person2':'Person100' }
Run Code Online (Sandbox Code Playgroud)
我试图在一个干净的图表中显示来自上述数据的层次结构图,如果我可以在可视化本身中过滤该数据,那就是一个奖励。
我得到的数据有时可能包含 5 个人或有时记录数超过 5000。
我已经尝试过这些方法,但它们离生成任何交互式图形还差得很远。
代码 -
尝试 1 -
import pandas as pd
import networkx as nx
d = {'PersonX': 'Person1', 'PersonY': 'Person1', 'PersonZ': 'Person2', 'Person1': 'Person100', 'Person2': 'Person100'}
df = pd.DataFrame(d.items(), columns=['Person', 'Manager'])
G = nx.from_pandas_edgelist(df, source='Person', target='Manager')
nx.draw(G, with_labels=True)
plt.show()
Run Code Online (Sandbox Code Playgroud)
尝试 2 -
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.preprocessing import LabelEncoder
from scipy.cluster import hierarchy
df2 = df.apply(LabelEncoder().fit_transform)
df2.set_index('Manager', inplace=True)
Z = hierarchy.linkage(df2, …Run Code Online (Sandbox Code Playgroud) 我正在尝试通过我的 Windows 和 Mac 系统连接到 AWS Athena。我的目标是拥有一个 SQL 编辑器,我可以用它来对数据进行快速研究。我试图找到连接到 Athena 的工具和教程。到目前为止,我只找到了一些关于 SQL Workbench 的教程。你们还有哪些其他工具可以使用,您是否特别喜欢该工具,以及在 Windows/Mac 上设置它是多么容易。
我正在尝试使用 Dash 显示数据框。我拥有的数据框是https://www.kaggle.com/timoboz/superbowl-history-1967-2020。我的目标是通过一个搜索按钮在网页上显示数据框,该按钮可动态搜索所有列并过滤数据框。
到目前为止,我有以下显示数据框的代码。
import pandas as pd
import dash
import dash_table
from dash.dependencies import Input, Output
df = pd.read_csv('./Data/superbowl.csv')
PAGE_SIZE = 10
app = dash.Dash(__name__)
app.layout = dash_table.DataTable(
id='datatable-paging',
columns=[
{"name": i, "id": i} for i in df.columns #sorted(df.columns)
],
page_current=0,
page_size=PAGE_SIZE,
page_action='custom',
sort_action='custom',
sort_mode='single',
sort_by=[]
)
@app.callback(
Output('datatable-paging', 'data'),
[Input('datatable-paging', "page_current"),
Input('datatable-paging', "page_size"),
Input('datatable-paging', 'sort_by')])
def update_table(page_current,page_size,sort_by):
if len(sort_by):
dff = df.sort_values(
sort_by[0]['column_id'],
ascending=sort_by[0]['direction'] == 'asc',
inplace=False
)
else:
# No sort is applied
dff = …Run Code Online (Sandbox Code Playgroud) pandas ×2
python-3.x ×2
graph ×1
jdbc ×1
mysql ×1
plotly ×1
plotly-dash ×1
python ×1
sql ×1
tree ×1