Posts

python - Efficiently joining two dataframes based on multiple levels of a multiindex -

i have dataframe large multiindex, , secondary dataframe multiindex subset of larger one. secondary dataframe kind of lookup table. want add columns lookup table larger dataframe. primary dataframe large, want efficiently. here imaginary example, want join df2 df1: in [11]: arrays = [ ['sun', 'sun', 'sun', 'moon', 'moon', 'moon', 'moon', 'moon'], ....: ['summer', 'winter', 'winter', 'summer', 'summer', 'summer', 'winter', 'winter'], ....: ['one', 'one', 'two', 'one', 'two', 'three', 'one', 'two']] in [12]: tuples = list(zip(*arrays)) in [13]: index = pd.multiindex.from_tuples(tuples, names=['body', 'season','item']) in [14]: df1 = pd.dataframe(np.random.randn(8,2), index=index,columns=['a','b']) in [15]: df...

wpf - Get a rectangle of a newly added ListViewItem -

i add new record listview's itemssource collection: source.add(newrecord); after action i'm trying rectangle of corresponding item: listviewitem newitem = list.itemcontainergenerator.containerfromitem(newrecord) listviewitem; rect rc = layoutinformation.getlayoutslot(newitem); but, unfortunately, rc (0, 0, 0, 0). seems when call getlayoutslot method, new listviewitem not yet arranged. how can obtain correct information directly after adding new record? any appreciated. calling list.updatelayout(); before line listviewitem newitem = ... should rectangle immediately. but generally, not recommend use updatelayout() anywhere in wpf program. layout procedures in wpf asynchronous performance reasons. therefore, better if program determined rectangles of list items @ later point in time. here mean "later point in time": source.add(newrecord); dispatcher.begininvoke(dispatcherpriority.loaded, new action(() => { listviewitem...

perlscript - Perl script appending date -

am running perl script ever day on server , getting below output script. trying modify script include current hour part of output. how can go doing this? this current script: #!/usr/bin/perl #prism performance log parser use strict; $cbal_total; $cbal_count =0; $stck_total = 0; $stck_count =0; $chg_total = 0; $chg_count =0; $rmac_total = 0; $rmac_count =0; $rmd_total = 0; $rmd_count =0; $cbalt; $stckt; $rmact; $rmdt; $chgt; $total; $count; $cbal; $stck; $hour; $chg; $rmac; $rmd; $lesthresh=0; $gtthresh=0; $stck_lesthresh=0; $stck_gtthresh=0; $rmd_lesthresh=0; $rmd_gtthresh=0; $chg_lesthresh=0; $chg_gtthresh=0; $rmac_lesthresh=0; $rmac_gtthresh=0; %checkbal; %subtypecheck; %charging; %remoteact; %remotedct; $chgkey; $cbalkey; $stckkey; $rmackey; $rmdkey; @value; $ct; $component; $component2; while (my $line =<>) { chomp; s/\r//g; @f = split(/\|/, $line); $i; $hour = substr($f[0],11,2); ($i==0;$i<=100; $i++) { if (($f[$i]=~m/c...

r - produce multiple time series in different plot and save in working directory -

this appears quite simple have no idea how go it. dataframe looks this: var1 var2 var3 var4 var5 var6 ..... var57 1 23 67 89 63 34 ..... 90 2 34 43 43 23 23 ..... 32 3 45 65 45 32 54 ..... 43 4 45 32 18 61 87 ..... 39 5 23 74 53 54 76 ..... 54 6 21 65 34 34 12 ..... 97 . . . . . . ..... . . . . . . . ..... . . . . . . . ..... . 365 54 78 54 12 90 ..... 53 i want produce separate plots , save them in working directory var1 against variables. plot(var1 ~ var2) plot(var1 ~ var3) plot(var1 ~ var4) plot(var1 ~ var5) . . . . . plot(var1 ~ var57) is there way automate dont have produce each individual plots @ time , save in working directory? thanks lot. pdf("plots.pdf") for(i in 2:ncol(df)) plot(df[,1] ~ df[,i]) dev.off()

linux - Bash reading from file and parsing each line -

this question has answer here: loop iterates once `ssh` in body [duplicate] 1 answer i need manage updates of particular software on several customers' linux servers. updates provided sending .tar.gz files each server , inflating overwriting old software files. i've put customers' server list in txt file this: user1@customer-server-1-address:22:/path/to/software/server1:null:customer1name user2@customer-server-2-address:2222:/path/to/software/server2:/etc/vpnc/client1.conf:customer2name user3@customer-server-3-address:22:/path/to/software/server3:null:customer3name char ":" acts field separator; field 1 server address, 2 port, 3 path software, 4 used tell if vpn tunnel enabled first, 5 customer name. i've managed create following script: #!/bin/bash [...] while ifs=':' read -ra array; if [ "${array[3]}" !=...

python - Why does deleting a directory structure and then re-creating it immediately after raise an exception? -

i've reduced issue this: import os, shutil shutil.rmtree("wtf", true) os.makedirs("wtf") now, when run following error: traceback (most recent call last): file "wtf.py", line 4, in <module> os.makedirs("wtf") file "c:\program files (x86)\python34\lib\os.py", line 244, in makedirs mkdir(name, mode) permissionerror: [winerror 5] access denied: 'wtf' what causing this?

html - Using ~ to make another element change style -

sorry misleading title, pretty hard describe problem in few words. basically want when hover on caption want headline block text underline. right have jsfiddle on every other caption 1 hovering. jsfiddle: http://jsfiddle.net/gnfpj/1/ css: .caption { width: 480px; height: 270px; float: left; margin-left: 5px; margin-top: 5px; } .caption p { background-color: #000; color: #fff; margin-top: -53px; height: 50px; padding: 7px; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; opacity: 0.7; font-family: verdana, sans-serif; font-size: 12px; line-height: 19px; } .caption p span { font-weight: bold; font-size: 14px; } .caption:hover ~ .caption p span { text-decoration: underline; } .caption { text-decoration: none; } you want simple descending selector: .caption:hover p span { text-decoration: underline; } http://jsfiddle.net/gnfpj/2/