public class ImageView extends JComponent {
protected static final Dimension DEFAULT_SIZE = new Dimension(480, 320);
private BufferedImage mImage;
private Timer invalidationTimer;
public ImageView() {
setBackground(Color.WHITE);
invalidationTimer = new Timer(100, new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
stateInvalidated();
}
});
invalidationTimer.setRepeats(false);
}
public ImageView(int width, int height) {
this();
mImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
clear();
}
@Override
public void invalidate() {
super.invalidate();
invalidationTimer.restart();
}
protected void stateInvalidated() {
System.out.println(getWidth() + "x" + getHeight());
}
public BufferedImage getImage() {
return mImage;
}
public void setImage(BufferedImage image) {
mImage = image;
}
public void clear() {
if (mImage == null) {
return;
}
Graphics g = mImage.getGraphics();
g.setColor(Color.WHITE);
g.fillRect(0, 0, mImage.getWidth(), mImage.getHeight());
g.dispose();
}
@Override
public Dimension getPreferredSize() {
return mImage == null ? DEFAULT_SIZE : new Dimension(mImage.getWidth(), mImage.getHeight());
}
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
if (mImage == null) {
return;
}
//g.setColor(Color.white);
//g.fillRect(0, 0, getWidth(), getHeight());
int x = (getWidth() - mImage.getWidth()) / 2;
int y = (getHeight() - mImage.getHeight()) / 2;
g.drawImage(mImage, x, y, this);
}
}
一行是Serias对象,打印输出如下:
for i,r in data.iterrows():
print(r)
我想:
该怎么做?
答案 0 :(得分:1)
- 删除所有值== Nan或0的QuantifierId(并保留所有 值== 1的QuantifierId)
data = data.loc[(data.QuantifierId.notnull()) & (data.QuantifierId != 0)]
- 从每一行获取该名称字段
data.index.tolist()