我有以下数据帧:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
x = np.arange(10)
x = np.concatenate((x,x))
y = []
for i in range(2):
y.append(np.random.random_integers(0,10,20))
d = {'A': [(x[i], y[0][i]) for i in range(20)],
'B': [(x[i], y[1][i]) for i in range(20)]}
df = pd.DataFrame(d, index = list('aaaaaaaaaabbbbbbbbbb'))
Run Code Online (Sandbox Code Playgroud)
DF
A B
a (0, 2) (0, 10)
a (1, 0) (1, 8)
a (2, 3) (2, 8)
a (3, 7) (3, 8)
a (4, 8) (4, 10)
a (5, 2) …Run Code Online (Sandbox Code Playgroud) 我在 Mac 中使用 PyQt5 创建 Qt 菜单栏时遇到问题。
我遇到的问题是菜单栏会出现,但在我取消关注应用程序(通过单击其他应用程序),然后再次重新聚焦 Qt 应用程序之前不会做出反应。
这是我的环境:
操作系统:塞拉利昂 10.12
Python:来自 conda 的 Python 3.6
PyQt5: conda 默认(v5.3.1)
这是我的代码(主要来自http://zetcode.com/gui/pyqt5/menustoolbars/):
import sys
from PyQt5.QtWidgets import QMainWindow, QAction, QDesktopWidget, QApplication, qApp, QMenuBar
class Example(QMainWindow):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
self.resize(800, 600)
self.center()
self.setWindowTitle('Menubar')
exitAction = QAction(' &Exit', self)
exitAction.setShortcut('Ctrl-Q')
exitAction.setToolTip('Exit application')
exitAction.triggered.connect(qApp.quit)
menubar = self.menuBar()
fileMenu = menubar.addMenu('&File')
fileMenu.addAction(exitAction)
self.show()
def center(self):
center_point = QDesktopWidget().availableGeometry().center()
frame = self.frameGeometry()
frame.moveCenter(center_point)
self.move(frame.topLeft())
if __name__ == '__main__': …Run Code Online (Sandbox Code Playgroud)