Posts

python - Optimizing dataframe manipulation: new column based on conditional logic and multiple columns -

currently, works: df['new'] = df.apply( \ lambda x: address[int(x['c1'][:5], 2)]+'_'+str(int(x['c1'][6:11], 2)) \ if x['c1'][5] == '1' \ else address[int(x['c2'][:5], 2)]+'_'+str(int(x['c2'][6:11], 2)), axis=1) ` address dictionary. but it's really slow . specifically, apply ing whole dataframe considerably slower apply ing selected column. however, new column based on multiple columns , i'm not sure how implement that. additionally, there way vectorize these types of logical/conditional statements? sample dataframe: <bound method dataframe.head of c1 c2 0 0000100111000111 0010110011000111 1 0001000111000111 0010110011000111 2 0101010001001010 0000000000000000 3 0101010010001110 0000000000000000 4 0101010011101010 0000000000000000 5 0111111100000100 0000000000000000 6 0111110010010110 000000...

html - How do I make multiple buttons and checkboxes moved through css interactable? -

i have page checkmark , 2 buttons. when move them through css cant interact them longer, have solved through using z-index: 1; , this: <div style="position: relative; bottom: +95; z-index: 1;"> <button name="" value="">bypass</button> <button name="open" value="n">bypass</button> </div> but when add checkbox under these buttons this: <div style="position: relative; bottom: +115px; font-size: 13px; margin-left: -435px;">1: <input type="checkbox" name="one" value="yes"></div> i can't interact it. i have tried adding z-index: 2; this: <div style="position: relative; bottom: +115px; font-size: 13px; margin-left: -435px; z-index: 2;">1: <input type="checkbox" name="one" value="yes"></div> which makes checkbox interactable, makes buttons un-interactable. how can make bot...

php - Trying to get property of non-object in Laravel 5 after upgrade -

i created first laravel package out of old php script teamspeak auth service. main app running laravel 4, has been upgraded laravel 5. package worked before, not. the error - [2017-08-17 22:04:29] local.error: errorexception: trying property of non-object in /apppath/vendor/eveseat/services/src/settings/settings.php:86 stack trace: #0 /apppath/vendor/eveseat/services/src/settings/settings.php(86): illuminate\foundation\bootstrap\handleexceptions->handleerror(8, 'trying p...', '/apppath/$ #1 /apppath/vendor/laravel/framework/src/illuminate/cache/repository.php(349): seat\services\settings\settings::seat\services\settings\{closure}() #2 /apppath/vendor/laravel/framework/src/illuminate/cache/cachemanager.php(301): illuminate\cache\repository->rememberforever('thkt2r21aa1vlkh...', object(closure)) #3 /apppath/bootstrap/cache/compiled.php(6468): illuminate\cache\cachemanager->__call('rememberforever', array) #4 /apppath/vendor/eveseat/services/sr...

r - odd behavior of print within mapply -

i seeing unexpected behavior (to me anyway) when print() included side effect in function wrapped in mapply() . for example, works expected (and yes know it's not how add vectors): mapply(function(i,j) i+j, i=1:3, j=4:6) # returns [1] 5 7 9 and this: mapply(function(i,j) paste(i, "plus", j, "equals", i+j), i=1:3, j=4:6) # returns [1] "1 plus 4 equals 5" "2 plus 5 equals 7" "3 plus 6 equals 9" but doesn't: mapply(function(i,j) print(paste(i, "plus", j, "equals", i+j)), i=1:3, j=4:6) # returns: # [1] "1 plus 4 equals 5" # [1] "2 plus 5 equals 7" # [1] "3 plus 6 equals 9" # [1] "1 plus 4 equals 5" "2 plus 5 equals 7" "3 plus 6 equals 9" what's going on here? haven't used mapply() in while, maybe no-brainer... i'm using r version 3.4.0. print both prints argument , returns value. p <- print("abc")...

javascript - Return Input from Custom Popup -

i working on custom modal popup entity. when need text value user, make html element visible, need value enter in text field when press "enter" button. the problem i'm trying doesn't seem have easy implementation. don't think it's possible without promises, , attempts far have not worked. ideas on possible solutions? turns out managed myself. had assumed promise somehow end when reached end of code, not true: continue when resolve manually. therefore when set onclick of button possibility of resolving it, wait button pressed. see code sample below: var modalpopup() = function() { //display popup document.getelementbyid("generalmodalbackground").style.display = "flex"; return new promise(function(resolve, reject) { document.getelementbyid("generalsubmitbutton").onclick = function() { //when clicked, resolve promise inputted value let returnval = document.getelementbyid("generaltextfield...

osx - Python- Google voice -

i trying use http://sphinxdoc.github.io/pygooglevoice/examples.html#send-sms-messages , getting error file "build/bdist.macosx-10.6-intel/egg/googlevoice/voice.py", line 72, in login attributeerror: 'nonetype' object has no attribute 'group' my code is: from googlevoice import voice googlevoice.util import input import sys username, password = "email@gmail.com", "password" voice = voice() voice.login(username, password) phonenumber = input('number send message to: ') text = input('message text: ') voice.send_sms(phonenumber, text) i wondering if login error or error in code? if so, how can edit code works? thank much! edit: have been researching , apparently it's common problem , have change line 72 in file voice.py can't find file: /usr/local/lib/python2.7/dist-packages/googlevoice/voice.py to install, did: $ pip install python python-setuptools $ sudo easy_install simplejson $ sudo easy_in...

android - notifyDataSetChanged() for Adapter on custom searchview -

i have customized searchview based on this library , use following method delete suggestions: public synchronized void removesuggestion(string suggestion) { if (!textutils.isempty(suggestion)) { mcontext.getcontentresolver().delete( historycontract.historyentry.content_uri, historycontract.historyentry.table_name + "." + historycontract.historyentry.column_query + " = ? , " + historycontract.historyentry.table_name + "." + historycontract.historyentry.column_is_history + " = ?" , new string[]{suggestion,string.valueof(0)} ); } madapter.notifydatasetchanged(); //don't works } it works. however, have notifydatasetchanged() adapter in order remove suggestions list right after h...