我可以成功运行代码,而无需错误的PF屏幕截图。也许您可以检查变形金刚版本吗?
我有一个使用Transformers Model/Tokenizers功能的COLAB笔记本电脑,也许您可以直接使用它们。
https://colab.research.google.com/drive/12gwdua-fs7h31hic5frzavt6ofyelwux?usp = sharing
我希望这会有所帮助!
以下是做您提出问题的两种方法,一种是使用大熊猫,另一种使用numpy(更新)在有关binning的评论中反映了有关binning的澄清,以基于连续分组的 bin 值):
res = df.assign(bin_index = (df.bin != df.bin.shift()).cumsum())
dfAggs = res[['butter', 'bin', 'bin_index']].groupby(['bin', 'bin_index']).agg([min, max])
dfAggs.columns = dfAggs.columns.droplevel()
res = res.join(dfAggs, on=['bin', 'bin_index']).drop(columns='bin_index')
print("", "pandas:", res, sep="\n")
a = df.copy().to_numpy()
print("", "input as numpy 2d array", a, sep="\n")
bin_index = a[:,2:3] != np.concatenate((np.full((1, 1), np.NaN), a[:-1,2:3]), axis = 0)
bin_index = np.cumsum(bin_index)
bins = np.unique(bin_index)
aggs = np.empty((a.shape[0], 2))
for b in bins:
mask = bin_index==b
aggs[mask, :] = (a[mask, 1].min(), a[mask, 1].max())
res = np.concatenate((a, aggs), axis=1)
print("", "numpy:", res, sep="\n")
输出:
input as pandas dataframe
time butter bin
0 2022-07-04 17:33:45+00:00 1.041967 3
1 2022-07-04 17:34:00+00:00 1.041967 4
2 2022-07-04 17:34:15+00:00 1.041966 4
3 2022-07-04 17:34:30+00:00 1.041967 4
4 2022-07-04 17:34:45+00:00 1.041968 4
5 2022-07-04 17:35:00+00:00 1.041969 4
6 2022-07-04 17:35:15+00:00 1.041971 4
7 2022-07-04 17:35:30+00:00 1.041973 4
8 2022-07-04 17:35:45+00:00 1.041975 4
9 2022-07-04 17:36:00+00:00 1.041977 5
10 2022-07-04 17:36:15+00:00 1.041979 5
11 2022-07-04 17:36:30+00:00 1.041981 5
12 2022-07-04 17:36:45+00:00 1.041983 5
13 2022-07-04 17:37:00+00:00 1.041985 5
14 2022-07-04 17:37:15+00:00 1.041986 6
15 2022-07-04 17:37:30+00:00 1.041987 6
16 2022-07-04 17:37:45+00:00 1.041988 6
17 2022-07-04 17:38:00+00:00 1.041989 6
18 2022-07-04 17:38:15+00:00 1.041990 4
19 2022-07-04 17:38:30+00:00 1.041995 4
pandas:
time butter bin min max
0 2022-07-04 17:33:45+00:00 1.041967 3 1.041967 1.041967
1 2022-07-04 17:34:00+00:00 1.041967 4 1.041966 1.041975
2 2022-07-04 17:34:15+00:00 1.041966 4 1.041966 1.041975
3 2022-07-04 17:34:30+00:00 1.041967 4 1.041966 1.041975
4 2022-07-04 17:34:45+00:00 1.041968 4 1.041966 1.041975
5 2022-07-04 17:35:00+00:00 1.041969 4 1.041966 1.041975
6 2022-07-04 17:35:15+00:00 1.041971 4 1.041966 1.041975
7 2022-07-04 17:35:30+00:00 1.041973 4 1.041966 1.041975
8 2022-07-04 17:35:45+00:00 1.041975 4 1.041966 1.041975
9 2022-07-04 17:36:00+00:00 1.041977 5 1.041977 1.041985
10 2022-07-04 17:36:15+00:00 1.041979 5 1.041977 1.041985
11 2022-07-04 17:36:30+00:00 1.041981 5 1.041977 1.041985
12 2022-07-04 17:36:45+00:00 1.041983 5 1.041977 1.041985
13 2022-07-04 17:37:00+00:00 1.041985 5 1.041977 1.041985
14 2022-07-04 17:37:15+00:00 1.041986 6 1.041986 1.041989
15 2022-07-04 17:37:30+00:00 1.041987 6 1.041986 1.041989
16 2022-07-04 17:37:45+00:00 1.041988 6 1.041986 1.041989
17 2022-07-04 17:38:00+00:00 1.041989 6 1.041986 1.041989
18 2022-07-04 17:38:15+00:00 1.041990 4 1.041990 1.041995
19 2022-07-04 17:38:30+00:00 1.041995 4 1.041990 1.041995
input as numpy 2d array
[['2022-07-04 17:33:45+00:00' 1.041967 3]
['2022-07-04 17:34:00+00:00' 1.041967 4]
['2022-07-04 17:34:15+00:00' 1.041966 4]
['2022-07-04 17:34:30+00:00' 1.041967 4]
['2022-07-04 17:34:45+00:00' 1.041968 4]
['2022-07-04 17:35:00+00:00' 1.041969 4]
['2022-07-04 17:35:15+00:00' 1.041971 4]
['2022-07-04 17:35:30+00:00' 1.041973 4]
['2022-07-04 17:35:45+00:00' 1.041975 4]
['2022-07-04 17:36:00+00:00' 1.041977 5]
['2022-07-04 17:36:15+00:00' 1.041979 5]
['2022-07-04 17:36:30+00:00' 1.041981 5]
['2022-07-04 17:36:45+00:00' 1.041983 5]
['2022-07-04 17:37:00+00:00' 1.041985 5]
['2022-07-04 17:37:15+00:00' 1.041986 6]
['2022-07-04 17:37:30+00:00' 1.041987 6]
['2022-07-04 17:37:45+00:00' 1.041988 6]
['2022-07-04 17:38:00+00:00' 1.041989 6]
['2022-07-04 17:38:15+00:00' 1.04199 4]
['2022-07-04 17:38:30+00:00' 1.041995 4]]
numpy:
[['2022-07-04 17:33:45+00:00' 1.041967 3 1.041967 1.041967]
['2022-07-04 17:34:00+00:00' 1.041967 4 1.041966 1.041975]
['2022-07-04 17:34:15+00:00' 1.041966 4 1.041966 1.041975]
['2022-07-04 17:34:30+00:00' 1.041967 4 1.041966 1.041975]
['2022-07-04 17:34:45+00:00' 1.041968 4 1.041966 1.041975]
['2022-07-04 17:35:00+00:00' 1.041969 4 1.041966 1.041975]
['2022-07-04 17:35:15+00:00' 1.041971 4 1.041966 1.041975]
['2022-07-04 17:35:30+00:00' 1.041973 4 1.041966 1.041975]
['2022-07-04 17:35:45+00:00' 1.041975 4 1.041966 1.041975]
['2022-07-04 17:36:00+00:00' 1.041977 5 1.041977 1.041985]
['2022-07-04 17:36:15+00:00' 1.041979 5 1.041977 1.041985]
['2022-07-04 17:36:30+00:00' 1.041981 5 1.041977 1.041985]
['2022-07-04 17:36:45+00:00' 1.041983 5 1.041977 1.041985]
['2022-07-04 17:37:00+00:00' 1.041985 5 1.041977 1.041985]
['2022-07-04 17:37:15+00:00' 1.041986 6 1.041986 1.041989]
['2022-07-04 17:37:30+00:00' 1.041987 6 1.041986 1.041989]
['2022-07-04 17:37:45+00:00' 1.041988 6 1.041986 1.041989]
['2022-07-04 17:38:00+00:00' 1.041989 6 1.041986 1.041989]
['2022-07-04 17:38:15+00:00' 1.04199 4 1.04199 1.041995]
['2022-07-04 17:38:30+00:00' 1.041995 4 1.04199 1.041995]]
熊猫说明:
- 一个ID值
- 创建
bin_index
列,该列检测bin
中的变化,并为每个这样的行使用dataframe.groupby()
基于bin_index
- 使用
data> dataframe 。
min
和Max
列到原始数据框架。
numpy说明:
- 创建
bin_index
数组,该数组在bin
中检测变化,并为每个这样的行增量一个ID值 - 准备
aggs
作为阵列A.形状[0],2
用于接收min
和max
相应bin
的列中的输入中的值ArrayA
- 使用布尔掩码对
bin_index
中的每个唯一bin
值使用butter
a
的列,并将这两个值放在aggs
的列中,这些行 - 使用
numpy.concatenate()
to to胶水a
和aggs
水平合在一起。
如果您的计算机上有一个预先存在的代码库(我认为是这种情况),并且您需要将此代码库“上传”到GitHub,则您需要执行一些操作:
-
在上github。如果您不熟悉命令行,建议您在Web UI上进行。您应该按照 @ben答案中的链接:在上github
-
初始化机器上的本地存储库。为此,您应该将终端和
cd
启动到代码库的文件夹中。CD/PATH/TO/您的/代码 git init
-
将您的本地存储库与GitHub上的远程存储库联系起来。
转到您新创建的回购,复制链接,如下图所示:确保您要复制
https
url。ssh
类型URL需要更多的配置,并且当您更愿意使用git
和ssh
tooling时,可以执行此操作。然后运行以下命令:
git Remote添加Origin<您的回购URL>
-
提交并推动您的代码。
git commit -a -m“初始提交” git推出原点 #您将需要输入您的用户名和密码
github要求如果您在命令行中推动代码,则需要使用个人访问令牌。您可以参考此链接为自己创建PAT。
下一步您应该更多地了解 git
工具。我建议阅读 atlassian的git tutorial ,或=“ https://git-scm.com/book/en/v2” rel =“ nofollow noreferrer”> git书
看来在Okhttp3中,它使用 proxy() okhttpclient.builder.builder 。 具有与中。
我最终尝试了所有内容,包括禁用缩放
,但是对我没有任何帮助。在与另一个项目进行比较之后,我发现显然 flutter Pub
很奇怪,并且使用 1.xx
作为版本约束(即使我通过 Flutter Pub添加)。
更改 pubspec.yaml
中的依赖项为 2.xx
工作:
dependencies:
....
firebase_core: ^2.7.1
请确保您使用的是: https://pub.dev/packages/firebase_core 。
如果您面临类似的问题,也可以为其他Firebase插件软件包做同样的事情。
我们总是可以写入
z = x xnor y
x,y,x是二进制变量的位置
z >= 1-x-y
z <= 1-x+y
z <= 1+x-y
z >= x+y-1
。这是严格的(派生为
有时,由于目标(或约束)的工作原理,我们可以放弃&lt; = or&gt; =不平等。
您可以解决此转换的方式之一,然后创建数据框架。
示例示例:
import pandas as pd
import numpy as np
def function(pages=0):
# Replace this with your logic
a=list(range(10))
b=[i*0.9 for i in a]
c=[i*0.5 for i in a]
return [a,b,c]
data=np.array(function()).T.tolist()
df=pd.DataFrame(data=data,columns=['A','B','C'])
输出:
In []: df
Out[25]:
A B C
0 0.0 0.0 0.0
1 1.0 0.9 0.5
2 2.0 1.8 1.0
3 3.0 2.7 1.5
4 4.0 3.6 2.0
5 5.0 4.5 2.5
6 6.0 5.4 3.0
7 7.0 6.3 3.5
8 8.0 7.2 4.0
9 9.0 8.1 4.5
尝试将 MAP
函数与结合使用
并返回合并的对象。
另外,您可能想将文件内容解析为JSON对象:
const arr1 = JSON.parse(fs.readFileSync('file1.txt', 'utf8'));
console.log(arr1);
const arr2 = JSON.parse(fs.readFileSync('file2.text', 'utf8'));
console.log(arr2);
const merge = (arr1, arr2) => {
return arr1.map(x => {
const y = arr2.find(val => val.customerid === x.customerid);
if (!y) return x;
return { ...x, ...y }
})
};
console.log(merge(arr1, arr2));
正如评论中所说,您有一个更改听众倾听所有结果的更改。每当更改结果之一时,将所有结果都添加到您的数组中并将其登录到控制台。
也许更改的侦听器不是您需要的 - 也许您可以在输入所有结果时让用户单击一个按钮,然后在按钮上单击创建数组。
否则,您可以解析数组并检查所有值是否具有长度?
const validArray = !array.some(item => item.length === 0);
(如果您的数组包含一个或多个空字符串的实例,则会返回false,如果您的数组有效。仅在值为True(如果值为true)时,请继续进行下一步)。
还请注意,您的数组是由字符串而不是整数组成的。我不确定这是否是您想要的。
fgets
可用于读取文件的每一行。
使用 strncmp
将行的第一个字符与序列号进行比较。 strncmp
将返回 0
for Match。
在比赛中, sscanf
可以从行中解析字段。 SCANSET %19 [^;];
最多将扫描19个不是半彩色的字符,然后扫描半彩色。
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main ( void)
{
char matricola[50] = "";
char line[100] = "";
printf("insert serial number: \n");
fgets ( matricola, sizeof matricola, stdin);
size_t length = strcspn ( matricola, "\n");
matricola[length] = 0; // remove newline
FILE *fp=fopen("prova.txt","r");
if (!fp){
printf("file doesnt exist\n");
return -1;
}
char (*matrice)[4][20] = NULL;
size_t rows = 0;
while ( fgets ( line, sizeof line, fp)) {
if ( ! strncmp ( line, matricola, length)) {
char (*temp)[4][20] = NULL;
if ( NULL == ( temp = realloc ( matrice, sizeof *matrice * ( rows + 1)))) {
fprintf ( stderr, "realloc problem\n");
free ( matrice);
return 1;
}
matrice = temp;
if ( 4 == sscanf ( line, "%19[^;];%19[^;];%19[^;];%19[^\n]"
, matrice[rows][0]
, matrice[rows][1]
, matrice[rows][2]
, matrice[rows][3])) {
++rows;
}
}
}
for ( size_t each = 0; each < rows; ++each) {
printf ( "%s\n", matrice[each][0]);
printf ( "%s\n", matrice[each][1]);
printf ( "%s\n", matrice[each][2]);
printf ( "%s\n\n", matrice[each][3]);
}
free ( matrice);
return 0;
}
type Option = {
value: any,
label: any
}
interface Role {
id: number
name: string
}
const roles: Role[] = [
{ id: 0, name: "foo" },
{ id: 1, name: "bar" },
{ id: 2, name: "baz" },
]
const result: Option[] = roles
.map(({ id, name }) => ({ label: id, value: name }));
console.log(result);
Result:
[LOG]: [{
"label": 0,
"value": "foo"
}, {
"label": 1,
"value": "bar"
}, {
"label": 2,
"value": "baz"
}]
它实际上删除了具有按钮的父元素。但这是 td
元素。您想删除 grand parent,所以要做:
el.parentElement.parentElement.remove();
仅查找最近的 tr
元素(在祖先元素中)可能会更容易:
el.closest("tr").remove();
function takeOut(el) {
el.closest("tr").remove();
}
document.getElementById('myButton').onclick = function() {
const name = document.getElementById('name').value;
const date = document.getElementById('date').value;
const amount = document.getElementById('amount').value;
const nameTd = '<td>' + name + '</td>';
const dateTd = '<td>' + date + '</td>';
const amountTd = '<td>' + '
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Expense Tracker</title>
</head>
<body>
<h1>Expense Tracker</h1>
<h3>Add A New Item:</h3>
<label>Name: <input text="text" id="name"></label><br>
<label>Date:<input type="date" id="date"></label><br>
<label>Amount:<input text="text" id="amount"></label><br>
<button type="button" id="myButton">Add Expense</button>
<button type="button" id="clearList">Clear List</button>
<br>
<br>
<br>
<br>
<br>
<table border="1">
<tr>
<th>Name</th>
<th>Date</th>
<th>Amount</th>
<th>Remove</th>
</tr>
<tbody id="table">
</tbody>
</table>
<script src="script2.js"></script>
</body>
</html>
+ amount + '</td>' + '<td>' +
'<button id="removeBtn"type="button" onClick="takeOut(this)">X</button></td>';
const tr = '<tr>' + nameTd + dateTd + amountTd + '</tr>';
document.getElementById('table').insertAdjacentHTML('beforeend', tr);
document.getElementById('clearList').onclick = function() {
const cl = document.getElementById('table');
while (cl.hasChildNodes()) {
cl.removeChild(cl.firstChild);
}
}
document.getElementById('name').value = '';
document.getElementById('amount').value = '';
document.getElementById('date').value = '';
}
使用别名:
Using alias:
如何从SQL Server中的选择中更新?