您不能直接使用crosstab
,这只会为您提供学生和项目的组合。
您可以做的是首先在“ project_id”
上执行数据框的合并以获取每个项目的所有组合,然后使用crosstab
:
df2 = df.merge(df, on='project_id', suffixes=('1','2'))
pd.crosstab(df2['student_id1'], df2['student_id2'])
nb。请小心,中间数据框df2
将增加许多行,因为每个项目都有学生
的
df = pd.DataFrame({'project_id': ['P1', 'P1', 'P2', 'P3', 'P3', 'P3'],
'student_id': [1,2,3,4,1,2]})
。
student_id2 1 2 3 4
student_id1
1 2 2 0 1
2 2 2 0 1
3 0 0 1 0
4 1 1 0 1
组合
! );
s = df.groupby('student_id')['project_id'].agg(set)
a = s.to_numpy()
out = pd.DataFrame(a&a[:, None], index=s.index, columns=s.index).applymap(len)
或者:
from itertools import combinations_with_replacement
s = df.groupby('student_id')['project_id'].agg(set)
df2 = pd.Series([len(a&b) for a,b in combinations_with_replacement(s, 2)],
index=pd.MultiIndex.from_tuples(combinations_with_replacement(s.index, 2))).unstack()
out = df2.combine_first(df2.T).convert_dtypes()
Flexbox方式,孤儿块伸展到父母的完整宽度(flex-grow:0;
将其关闭)。有自己的缺点和更多的代码。
#about {
display: flex;
flex-wrap: wrap;
}
#about > * {
flex-basis: 100%;
}
#about > blockquote {
flex-basis: 50%;
flex-grow: 1;
margin: 0;
/* just to higlight the structure */
box-sizing: border-box;
border: 1px solid #00f1;
background: #f001;
}
<div id="about">
<h1>About</h1>
<blockquote>1</blockquote>
<blockquote>2</blockquote>
<blockquote>3</blockquote>
<p>some text</p>
<blockquote>4</blockquote>
<blockquote>5</blockquote>
<blockquote>6</blockquote>
<blockquote>7</blockquote>
</div>
在检查状态之前,您需要锁定订单。
如果2个并发请求执行检查请求。 ||订单。拒绝?
与您的解决方案同时获得false
,并在锁定下进行。
更改您的模型
class Request < ApplicationRecord
def self.reject_request(key)
request = Request.where(:reject_key => key).first
order = request&.order
# make sure both request and order objects are not empty
raise ActiveRecord::Rollback if request.blank? || order.blank?
# lock your object
order.lock!
request.lock!
# put your conditions here after the `lock`
raise ActiveRecord::Rollback if request.rejected? || order.rejected?
request.status = 'rejected'
request.save!
order.update(status: 'rejected')
true
end
end
您的问题可能是0
.data 字段中的是字符串,如果是数字。
我可以使用format_value('0',“%0.03F”)
重现相同的错误。
查看当前我们可以看到,它从字符串中删除了所有尾随零,尤其是format_value('100',“%0.03F”)
给出1
。
这是一个错误,应替换正则义务(例如,使用: https://stackoverflow.com/A )
请注意,当您提供一个数字(例如100或0)时,该数字首先替换为字符串(100.000
或0.000
),因此该函数不会用数字(int或float)调用时显示其错误。
此外,shap
的开发版本(尚未发布)不会遭受此问题的困扰,因为当调用非数字值时,函数waterfall_plot
不会调用format_value
,请参阅:
/Github.com/slundberg/shap/issues/2581#issuecomment-11555134604“ rel =“ nofollow noreferrer”> https://github.com/slundberg/slundberg/shap/shap/shap/shap/shap/shap/shap/2581#issuecomment-11555134604604
6个不同的方法可以通过数组循环循环,
您可以通过许多不同的方法循环循环数组。我已经从上到下整理了6种喜欢的方法。
1。使用 javascript用于循环
代码> 循环是我的首选。
let array = [1, 2, 3, 4, 5];
for (let i = 0; i < array.length; i++) {
console.log(array[i]);
}
2。使用foreach循环
foreach
循环是循环循环段的现代方法。同样,它具有更大的灵活性和控制阵列和元素。
let array = [1, 2, 3, 4, 5];
array.forEach((element) => {
console.log(element);
});
3。使用... of
for ... of
循环使您可以直接访问数组元素。
let array = [1, 2, 3, 4, 5];
for (let element of array) {
console.log(element);
}
4。使用... in循环
for ... in
为您提供一个可以访问数组元素的键。
let array = [1, 2, 3, 4, 5];
for(let index in array){
console.log(array[index]);
}
5。在循环时使用时
,也可以使用循环循环循环。
let array = [1, 2, 3, 4, 5];
let length = array.length;
while(length > 0){
console.log(array[array.length - length]);
length--;
}
6。使用...循环
同样,我使用do ... while
循环
let array = [1, 2, 3, 4, 5];
let length = array.length;
do {
console.log(array[array.length - length]);
length--;
}
while (length > 0)
这是因为您试图在字符串上调用.addeventListener
(在这种情况下为“ .quiz-for”)。您应该在HTML元素上调用它(在您的情况下<代码>表单)。
更改:
const form = document.querySelector = ('.quiz-form');
到:
const form = document.querySelector('.quiz-form');
让我知道您是否需要更多解释。
由于您没有提供您的代码,所以我写了一些东西。
// example with list
const [list, setList] = React.useState([]);
// do as much as checkbox as you want, but
// with different value
<input
type={"checkbox"}
value={some_value}
checked={list.includes(some_value)}
onChange={(e) => {
e.target.checked
? setList([...list, e.target.value])
: setList([...list].filter((o) => o !== e.target.value));
}}
/>;
// on submit or click of button
const onSubmit = () => {
setList([]);
};
value['courses'].forEach((val) {
print(val);
});
//你可以尝试一下吗
您可以尝试将以下属性添加到文本字段:
1- textAlignVertical:textalignvertical.center
2-输入depecoration添加contentpadding:edgeinsets.only(top:0)
3-在iconbutton in iconbutton添加addding:edgeinsets.only(top:0)
TextField(
textAlignVertical: TextAlignVertical.center,
decoration: InputDecoration(
contentPadding: EdgeInsets.only(top: 0),
prefixIcon: Icon(
Icons.search,
),
hintStyle: TextStyle(
fontSize: 20,
),
suffixIcon: IconButton(
padding: EdgeInsets.only(top: 0),
icon: Icon(Icons.cancel),
onPressed: null,
),
hintText: "Search"
)
)
尽管没有直接回答这个问题,但我想在其他答案之上分享一个想法。从我那里得到的每一个都将提供一定程度的复杂性来实现跨平台独立性。
在我的情况下,我最初想要的只是设置一个变量来控制服务器是否使用JWT身份验证(用于开发目的)
在阅读答案后,我决定简单地创建2个不同的文件,并分别打开身份验证,并关闭身份验证。
"scripts": {
"dev": "nodemon --debug index_auth.js",
"devna": "nodemon --debug index_no_auth.js",
}
这些文件只是调用原始index.js文件的包装器(我将其重命名为appbootstrapper.js
):
//index_no_auth.js authentication turned off
const bootstrapper = require('./appbootstrapper');
bootstrapper(false);
//index_auth.js authentication turned on
const bootstrapper = require('./appbootstrapper');
bootstrapper(true);
class AppBootStrapper {
init(useauth) {
//real initialization
}
}
也许这可以帮助他人
您对is_tax()
的条件是正确的,应该可以正常工作。
如果您的ACF字段在分类学术语页面上,则需要在get_field
中指定术语的对象 - 在文档中解释了这一点 - 将ACF添加到税收
如果是这样,则应该有效。
function taxonomy_style() {
if ( is_tax( 'project_category' ) ) {
$project_category_css = get_field( 'project_category_css', get_queried_object() );
wp_enqueue_style( 'project_category_css', get_stylesheet_directory_uri() . $project_category_css );
}
}
add_action( 'wp_enqueue_scripts', 'taxonomy_style', 99 );
我的专业文件:
QT += core
QT -= gui
CONFIG += c++11
TARGET = openCV
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
INCLUDEPATH += C:\opencv\release\install\include
LIBS += C:\opencv\release\bin\libopencv_core455.dll
LIBS += C:\opencv\release\bin\libopencv_highgui455.dll
LIBS += C:\opencv\release\bin\libopencv_imgcodecs455.dll
LIBS += C:\opencv\release\bin\libopencv_imgproc455.dll
LIBS += C:\opencv\release\bin\libopencv_calib3d455.dll
LIBS += C:\opencv\release\bin\libopencv_features2d455.dll
LIBS += C:\opencv\release\bin\libopencv_video455.dll
LIBS += C:\opencv\release\bin\libopencv_videoio455.dll
LIBS += -L"(C:\Program Files(x86)\Tesseract-OCR)" -ltesseract
INCLUDEPATH += /usr/include/tesseract
INCLUDEPATH += C:\Program Files(x86)\Tesseract-OCR)
LIBS += C:\Program Files(x86)\Tesseract-OCR)
LIBS +=-LC:\Program Files(x86)\Tesseract-OCR)
-ltesseract.dll
-llept.dll
LIBS += -LC:\Qt\opencv_cv2\OPENCV1\build-qt\lib
-lopencv_calib3d249d
-lopencv_contrib249d
-lopencv_core249d
-lopencv_features2d249d
-lopencv_flann249d
-lopencv_gpu249d
-lopencv_highgui249d
-lopencv_imgproc249d
-lopencv_legacy249d
-lopencv_ml249d
-lopencv_nonfree249d
-lopencv_objdetect249d
-lopencv_ocl249d
-lopencv_photo249d
-lopencv_stitching249d
-lopencv_superres249d
-lopencv_ts249d
-lopencv_video249d
-lopencv_videostab249d
SOURCES += main.cpp
DEFINES += QT_DEPRECATED_WARNINGS
首先,检查是否允许质量分配字段 > name ,<代码>电子邮件和password
public function create()
{
$roles = Role::where('id', '<=', 6)->orderby('id')->get();
//$external = Role::where('id', '=', 2)->get();
// no need in second request as you already have role with id 2 in $roles
$external = $roles->firstWhere('id', 2);
// if id = 2 may change in future then
// $roles = Role::where('id', '<=', 6)->orWhere('id', $notOnly2)->orderby('id')->get();
}
函数rando_password
可以用str :: random($ length)
str 代码>( docs )
它在代码中是一个简单的修复程序,只需将导入语句
import ReactMarkdown from 'react-markdown';
从
import ReactMarkdown from 'react-markdown/react-markdown.min';
grid
GRID
我如何在DIV块内(水平和垂直)中心文本?