小编Gio*_*tos的帖子

python tkInter浏览文件夹按钮

我想使用tkinter创建一个浏览文件夹按钮,并将路径存储到变量中.到目前为止,我能够打印路径,但我无法将其存储在变量中.你能给些建议么?

下面我附上我使用的代码.

from tkinter import filedialog
from tkinter import *

def browse_button():
    filename = filedialog.askdirectory()
    print(filename)
    return filename


root = Tk()
v = StringVar()
button2 = Button(text="Browse", command=browse_button).grid(row=0, column=3)

mainloop()
Run Code Online (Sandbox Code Playgroud)

提前谢谢你!

python tkinter python-3.x

10
推荐指数
1
解决办法
2万
查看次数

在熊猫中组合多种样式

我想问一下是否有可能在熊猫中组合不同的样式格式。例如,我想一次组合以下4种样式。

df.style.format({'vm_unity': '{:.2%}'}).bar(subset=['vm_unity'], align='mid', color=['#d65f5f', '#5fba7d'])
df.style.bar(subset=['vm_top'], align='mid', color=['#d65f5f', '#5fba7d'])
df.style.bar(subset=['vm_bot'], align='mid', color=['#d65f5f', '#5fba7d'])
df.style.bar(subset=['Sy'], align='mid', color=['#d65f5f', '#5fba7d'])
Run Code Online (Sandbox Code Playgroud)

我目前执行的方式是将它们合并成一行,但是我认为这不是最优雅的方式

df.style.format({'vm_unity': '{:.2%}'}).bar(subset=['vm_unity'], align='mid', color=['#d65f5f', '#5fba7d']).bar(subset=['vm_top'], align='mid', color=['#d65f5f', '#5fba7d']).bar(subset=['vm_bot'], align='mid', color=['#d65f5f', '#5fba7d']).bar(subset=['Sy'], align='mid', color=['#d65f5f', '#5fba7d'])

您能不能打出更有效的方法?

先感谢您!

python pandas

5
推荐指数
1
解决办法
1783
查看次数

Pandas数据帧在不同的数据帧中查找值并分配值

我有2个不同的数据帧.第一个看起来像:

     joint  label     x    z      y    pt
0        1    NaN  50.4  0.0  -8.40    10
1        2  shell  52.2  0.0  -8.40    20
2        3  shell  54.0  0.0  -8.40    30
3        4  shell  55.8  0.0  -8.40    40
4        5  shell  57.6  0.0  -8.40    50
Run Code Online (Sandbox Code Playgroud)

我的第二个数据框看起来像:

     member  joint1  joint2        joint1_pt        joint2_pt
0         1       1       2                0                0
1         2       2       3                0                0
2         3       3       4                0                0
3         4       4       5                0                0
Run Code Online (Sandbox Code Playgroud)

我想使用在特定连接上对应的pt值并在第二个数据帧上使用它,因此它将如下所示:

     member  joint1  joint2        joint1_pt        joint2_pt …
Run Code Online (Sandbox Code Playgroud)

python dataframe python-3.x pandas

2
推荐指数
1
解决办法
6917
查看次数

标签 统计

python ×3

pandas ×2

python-3.x ×2

dataframe ×1

tkinter ×1