Posts

python - Merging two Pandas series with duplicate datetime indices -

i have 2 pandas series (d1 , d2) indexed datetime , each containing 1 column of data both float , nan. both indices @ one-day intervals, although time entries inconsistent many periods of missing days. d1 ranges 1974-12-16 2002-01-30. d2 ranges 1997-12-19 2017-07-06. period 1997-12-19 2002-01-30 contains many duplicate indices between 2 series. data duplicated indices same value, different values, or 1 value , nan. i combine these 2 series one, prioritizing data d2 anytime there duplicate indices (that is, replace d1 data d2 data anytime there duplicated index). efficient way among many pandas tools available (merge, join, concatenate etc.)? here example of data: in [7]: print d1 flddate 1974-12-16 19.0 1974-12-17 28.0 1974-12-18 24.0 1974-12-19 18.0 1974-12-20 17.0 1974-12-21 28.0 1974-12-22 28.0 1974-12-23 10.0 1974-12-24 6.0 1974-12-25 5.0 1974-12-26 12.0 1974-12-27 19.0 1974-12-28 22.0 1974-12-29 20.0 1974-12-30 16.0 1974-12-...

javascript - Why are these tests passing? -

i have function: let removepresentation = function(presentationname, callback) { let rimraf = require('rimraf'); callback(); callback(); callback(); if(!presentationname || !presentationname.trim()) { callback(); return; } presentationname = presentationname.replace('.zip', ''); rimraf('./presentations/' + presentationname, function(err) { if(err) { console.log(err); } callback(); }); }; exports.removepresentation = removepresentation; and trying test following: var chai = require('chai'), expect = require('chai').expect, sinonchai = require('sinon-chai'), sinon = require('sinon'), mock = require('mock-require'); chai.use(sinonchai); describe('removepresentation', function() { var sandbox; var callback; var rimrafspy; beforeeach(function() { sandbox = sinon.sandbox.create(); mock('../business/communications_business', {})...

python 3.x - How to programically quit mainloop via a tkinter canvas Button -

my program generates several graphs 1 @ time , each has quit button. program pauses in mainloop until press button, generates next graph. i way programmically press or invoke action associated button, in case root.quit() i have tried calling invoke() on button doesn't work. feeling event lost before mainloop started. from tkinter import * pause = false # passed in arg root = tk() root.title(name) canvas = canvas(root, width=canvas_width, height=canvas_height, bg = 'white') canvas.pack() quit = button(root, text='quit', command=root.quit) quit.pack() # make sure drawn canvas.update() if not pause: # invoke button event can draw next graph or exit quit.invoke() root.mainloop() i realised problem event being lost , mainloop blocking used pause arg determine when run mainloop , i.e. on last graph. see tkinter understanding mainloop all graphs displayed , when press quit on window windows disappear , program ends. if...

android - What is the `Authorization` part of the http post request of Google's Firebase Downstream message? -

Image
i want try send message using google's fcm messaging service , document says, http request should this: https://fcm.googleapis.com/fcm/send content-type:application/json authorization:key=aizasyz-1u...0gbyzpu7udno5aa { "data": { "score": "5x1", "time": "15:10" }, "to" : "bk3rnwte3h0:ci2k_hhwgipodkcizvvdmexudfq3p1..." } my problem have not idea authorization 's value should , when delete header , make request, error 401:unauthorized .i think must kind of api key or cannot find in project. can me? ps: testing purposes using this site send messsage device according about firebase cloud messaging server documentation: authentication to send message, app server issues post request. example: https://fcm.googleapis.com/fcm/send a message request consists of 2 parts: http header , http body. the http header must contain following headers: auth...

python - Early stopping in lgbm or xgb if score doesn't improve "enough" -

is there way, in xgboost or lgbm in python perform stopping if score doesn't improve more threshold? i know early_stopping_rounds = n makes algorithm stop if score hasn't improved on evaluation set during n consecutive iterations, if score doesn't improve more fixed threshold. i have learning task, in score on cv improves 0.65 0.25 in first 50 rounds (it's binary logloss) , continues on 1000 rounds achieve score of 0.241 . rather stop when score doesn't improve more 0.001 in 10 rounds. there way that?

amazon ec2 - Store ansible output to variable -

i want use ansible information aws ec2 instance. looking it's instance-id. going use loop through template. can't seem instance-id. here have far: --- - name: including variables include_vars: file: linux.yml - name: gathering ec2 facts ec2_remote_facts: aws_access_key: "{{ access_key }}" aws_secret_key: "{{ secret_key }}" region: us-east-1 filters: "tag:name": "{{ ansible_hostname }}" register: instanceid - debug: var=instanceid.instances.id i know incorrect when run get: "instanceid.instances.id": "variable not defined!" can tell me of way return instanceid? if first time, gradually... understand what's inside. like: - debug: var=instanceid # see raw result , find out `instances` there - debug: var=instanceid.instances # see `instanses` is, , see list - debug: var=instanceid.instances[0] # see first element of list , see it's properties - debug:...

Delphi - Extract multiple substrings from a string -

i have string ";;;caption=c:;freespace=103571001344;size=162527178752;;;caption=d:;freespace=129889742848;size=336805752832;;;caption=v:;freespace=516807241728;size=1000207282176;;;; how can extract each partition data variable obtain this: partition_1:='caption=c:;freespace=103571001344;size=162527178752'; partition_2:='caption=d:;freespace=129889742848;size=336805752832'; partition_n:='caption=v:;freespace=516807241728;size=1000207282176'; thank you! this question applies well. basically, use tstringlist , set linebreak property 3 semicolons ( ;;; ) , text property string.