上面的操作似乎有点琐事,但是,我对操作的输出有些迷惑。下面是一段代码来说明我的观点。
Dropzone.autoDiscover = false;
var myDropzone = new Dropzone('#upload-file-form', {
paramName: "file",
url: '/upload-file',
method: 'post',
acceptedFiles: ".png,.jpg,.gif,.jpeg",
maxFilesize: 256,
maxFiles: 1,
maxfilesexceeded: function(file) {
this.removeAllFiles();
this.addFile(file);
},
parallelUploads: 1,
uploadMultiple: false,
autoProcessQueue: false,
addRemoveLinks: false,
clickable: ".addFileButton",
previewsContainer: ".dropzone-previews",
});
$('#btnUpload').on('click', function(){
//redirect to new page (i.e myNewPage.php) along with the image
window.location.replace("");
});
以上代码的结果为:
# sample data for understanding concept of boolean indexing:
d_f = pd.DataFrame({'x':[0,1,2,3,4,5,6,7,8,9], 'y':[10,12,13,14,15,16,1,2,3,5]})
# changing index of dataframe:
d_f = d_f.set_index([list('abcdefghig')])
# a list of data:
myL = np.array(range(1,11))
# loop through data to boolean slicing and indexing:
for r in myL:
DF2 = d_f['x'].values == r
但是 myL 中的所有值都在 d_f ['x'] 中。除了 0 以外的其他值。因此,似乎该程序正在对 myL 和 d_f ['x'] .values中的元素进行“索引索引”匹配。这是熊猫图书馆的典型行为吗?如果是这样,请您为我解释一下其背后的理由。先感谢您。
答案 0 :(得分:0)
按照@coldspeed的状态,您正在用d_f['x'] == 10
覆盖DF2,这是所有False的布尔序列。
我想您要尝试的是这样:
d_f['x'].isin(myL)
输出:
a False
b True
c True
d True
e True
f True
g True
h True
i True
g True
Name: x, dtype: bool