我从4 df收集数据,并希望通过rownames合并它们.我正在寻找一种有效的方法来做到这一点.这是我拥有的数据的简化版本.
df1 <- data.frame(N= sample(seq(9, 27, 0.5), 40, replace= T),
P= sample(seq(0.3, 4, 0.1), 40, replace= T),
C= sample(seq(400, 500, 1), 40, replace= T))
df2 <- data.frame(origin= sample(c("A", "B", "C", "D", "E"), 40,
replace= T),
foo1= sample(c(T, F), 40, replace= T),
X= sample(seq(145600, 148300, 100), 40, replace= T),
Y= sample(seq(349800, 398600, 100), 40, replace= T))
df3 <- matrix(sample(seq(0, 1, 0.01), 40), 40, 100)
df4 <- matrix(sample(seq(0, 1, 0.01), 40), 40, 100)
rownames(df1) <- paste("P", sprintf("%02d", c(1:40)), sep= "")
rownames(df2) …Run Code Online (Sandbox Code Playgroud) 我对python很新,我不知道怎么做以下.
我有一个foo包含某个图的元数据和测量值的列表.例如,plotID,调查日期,测量员的首字母,几个测量值和一个分类变量.
foo= ['plot001', '01-01-2013', 'XX', '10', '12.5', '0.65', 'A']
Run Code Online (Sandbox Code Playgroud)
因为这些数据是从.txt读取的,所以所有列表项都是字符串.我的问题是:如何将每个列表项转换为适当的数据类型?.我可以创建一个包含所需数据类型的列表:
dType= ['str', 'str', 'str', 'int', 'float', 'float', 'float', 'str']
Run Code Online (Sandbox Code Playgroud)
如果我可以将dTypeas函数中的每个项目应用于匹配元素,那将是很好的foo:
out= [str(foo[0]), str(foo[1]), str(foo[2]), int(foo[3]), float(foo[4]), float(foo[5]), float(foo[6]), str(foo[7])]
Run Code Online (Sandbox Code Playgroud)
但我相信一定有更好的解决方案!谢谢你的任何建议!
我正试图为R情节制作整洁xlim和ylim价值观.我想:1)舍xlim[2]入到最接近的0.5的倍数,该倍数大于值向量中的最大值,2)舍xlim[1]入到最接近的0.5的倍数,该倍数小于值向量中的最小值.
例如
x <- c(1.2, 2, 3.4)
y <- c(0.7, 2, 3.7)
# The desired lim values are then
xlim <- c(1, 3.5)
ylim <- c(0.5, 4)
plot(x, y, xlim= xlim, ylim= ylim)
Run Code Online (Sandbox Code Playgroud)
提前感谢任何提示!
I'm trying to build a simple online quiz using Flask and Python 3.6, using HTML forms with radio buttons to carry the selected answers between Flask routes. The first step is to select a category for the quiz, before leading to the actual quiz page, as follows:
app = Flask(__name__)
categories = ['Europe', 'South America', 'North America']
@app.route('/')
def select():
return render_template('selecting.html', cats= categories)
@app.route('/quiz', methods = ['POST'])
def quizing():
selected_cat = request.form['categories']
return "<h1>You have selected category: " + …Run Code Online (Sandbox Code Playgroud)