col

python3迷宫,多线程版

三世轮回 提交于 2019-12-03 04:17:11
直接上代码 1 #!/usr/bin/python3 2 #coding=GB2312 3 import tkinter as tk 4 import threading 5 import time 6 import random 7 import sys 8 9 class Cell(): 10 def __init__(self, row, col): 11 self.row, self.col = row, col 12 self.top, self.right, self.bottom, self.left = True, True, True, True 13 self.visited = False 14 def __str__(self): 15 return 'row:{} col:{}--{} {} {} {}'.format( \ 16 self.row, self.col, self.top, self.right, \ 17 self.bottom, self.left) 18 def setVisited(self): 19 self.visited = True 20 def isVisited(self): 21 return self.visited 22 23 class Maze(threading.Thread): 24 colCount =

Error using corrplot

匿名 (未验证) 提交于 2019-12-03 03:06:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I need help with interpreting an error message using corrplot. Here is my script install.packages("ggplot2") install.packages("corrplot") install.packages("xlsx") library(ggplot2) library(corrplot) library(xlsx) #set working dir setwd("C:/R") #read xlsx data into R df <- read.xlsx("TP_diff_frame.xlsx",1) #set column as index rownames(df) <- df$country #remove column df2<-subset(df, select = -c(country) ) #round values to to decimals corrplot(df2, method="shade",shade.col=NA, tl.col="black", tl.srt=45) My df2: > df2 a b c d e f g Sweden 0.09

How to align RGB and Depth image from Kinect in Matlab

匿名 (未验证) 提交于 2019-12-03 02:52:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am trying to align RGB and Depth image from Kinect using Matlab. I am trying to do it using the algorithm from this page. Here is the code I have written so far depth = imread('depth_00500.png'); color = imread('rgb_00500.png'); rotationMat=[9.9984628826577793e-01 1.2635359098409581e-03 -1.7487233004436643e-02; -1.4779096108364480e-03 9.9992385683542895e-01 -1.2251380107679535e-02; 1.7470421412464927e-02 1.2275341476520762e-02 9.9977202419716948e-01 ]; translationMat=[1.9985242312092553e-02, -7.4423738761617583e-04, -1.0916736334336222e-02

P2486 [SDOI2011]染色

怎甘沉沦 提交于 2019-12-03 02:44:48
题面: https://www.luogu.org/problem/P2486 本题是树上染色+查询不同颜色个数,注意合并的时候左子树最右和右子树最左如果颜色相同的话那么总颜色数就要-- Code: #include<iostream> #include<cstdio> #include<cstring> #include<queue> #include<algorithm> #include<ctime> #include<queue> #include<vector> using namespace std; const int N=200005; int n,q,a[N],head[N],fa[N],son[N],siz[N],dep[N],top[N],id[N],rk[N],dfn,cnt; struct node{ int l,r,col,left,right,lazy; }t[N<<2]; struct Node{ int u,v,nxt; }edge[N<<1]; void add(int u,int v){ edge[++cnt]=((Node){u,v,head[u]}); head[u]=cnt; } void dfs1(int u,int f,int depth){ fa[u]=f; dep[u]=depth; siz[u]=1; for(int i

Show 2d-array in DataGridView

匿名 (未验证) 提交于 2019-12-03 02:43:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a 2D array. I want to print the array in my DataGridView but it throws an error: [Argument OutOfRangeException was unhandled ] This is my code for (int j = 0; j < height; j++) { for (int i = 0; i < width; i++) { dataGridView1[i, j].Value = state[i, j].h; //state[i, j].h this is my array dataGridView1[i, j].Style.BackColor pixelcolor[i,j]; dataGridView1[i, j].Style.ForeColor = Color.Gold; } } 回答1: As comments have pointed out, you should focus on rows and cells. You need to build your DataGridView columns and then populate each row

scipy.sparse.coo_matrix how to fast find all zeros column, fill with 1 and normalize

匿名 (未验证) 提交于 2019-12-03 02:42:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: For a matrix, i want to find columns with all zeros and fill with 1s, and then normalize the matrix by column. I know how to do that with np.arrays [[0 0 0 0 0] [0 0 1 0 0] [1 0 0 1 0] [0 0 0 0 1] [1 0 0 0 0]] | V [[0 1 0 0 0] [0 1 1 0 0] [1 1 0 1 0] [0 1 0 0 1] [1 1 0 0 0]] | V [[0 0.2 0 0 0] [0 0.2 1 0 0] [0.5 0.2 0 1 0] [0 0.2 0 0 1] [0.5 0.2 0 0 0]] But how can I do the same thing when the matrix is in scipy.sparse.coo.coo_matrix form, without converting it back to np.arrays. how can I achieve the same thing? 回答1: This will be a lot

Problems with adding a new column to a dataframe - spark/scala

匿名 (未验证) 提交于 2019-12-03 02:38:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am new to spark/scala. I am trying to read some data from a hive table to a spark dataframe and then add a column based on some condition. Here is my code: val DF = hiveContext.sql("select * from (select * from test_table where partition_date='2017-11-22') a JOIN (select max(id) as bid from test_table where partition_date='2017-11-22' group by at_id) b ON a.id=b.bid") def dateDiff(partition_date: org.apache.spark.sql.Column, item_due_date: org.apache.spark.sql.Column): Long ={ ChronoUnit.DAYS.between(LocalDate.parse(partition_date.toString

MatLab (or any other language) to convert a matrix or a csv to put 2nd column values to the same row if 1st column value is the same?

匿名 (未验证) 提交于 2019-12-03 02:38:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: So for example I have 1st column | 2nd column 1 1 1 3 1 9 2 4 2 7 I want to convert it to 1st column | 2nd column | 3rd column | 4th column 1 1 3 9 2 4 7 3 The (3,4) element should be empty. I can do it by Matlab using for and if but it takes too much time for huge data, so I need a more elegant and brilliant idea. I prefer Matlab but other languages are ok. (I can export the matrix to csv or xlsx or txt and use the other languages, if that language can solve my problem.) Thank you in advance! [Updates] If A = [2 3 234 ; 2 44 33; 2 12 22; 3

pandas: to_numeric for multiple columns

匿名 (未验证) 提交于 2019-12-03 02:20:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm working with the following df : c.sort_values('2005', ascending=False).head(3) GeoName ComponentName IndustryId IndustryClassification Description 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 37926 Alabama Real GDP by state 9 213 Support activities for mining 99 98 117 117 115 87 96 95 103 102 (NA) 37951 Alabama Real GDP by state 34 42 Wholesale trade 9898 10613 10952 11034 11075 9722 9765 9703 9600 9884 10199 37932 Alabama Real GDP by state 15 327 Nonmetallic mineral products manufacturing 980 968 940 1084 861 724 714 701 589

&#039;int&#039; object has no attribute &#039;__getitem__&#039;

匿名 (未验证) 提交于 2019-12-03 02:11:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: import math import os class collection: col = [[0 for col in range(5)] for row in range(6)] dist = [[0 for col in range(6)] for row in range(6)] filename = "" result = "" def __init__(self,arg1): self.filename = arg1 def coll(self): for i in range(6): try: if(i==0): f = open(self.filename,'r') elif(i==1): f = open("chap1.txt",'r') elif(i==2): f = open("chap2.txt",'r') elif(i==3): f = open("chap3.txt",'r') elif(i==4): f = open("chap4.txt",'r') elif(i==5): f = open("chap5.txt",'r') for j in range(5): self.result = f.readline() self.col[i][j] =