Posts

Spark Dataframe order preservation .Does calling the save operation on orderBy dataframe preserves ordering -

i ran test cases spark shell . statement executed of form . read.orderby($"p_int".asc ).write.format("com.databricks.spark.csv").save(“file:///tmp/output.txt”) the content in output directory seems sorted. cannot find documentation in spark related guarantees provided either dataframewriter in terms of preserving partition order or row order. the question can expect data in target file sorted ?and please add link proper documentation. if coalesce 1 partition before saving, output sorted. careful thought, when reading .csv in spark, if in spark config spark.default.parallelism more 1, ordering lost.

Can't move folder in android terminal -

i'm trying write small backup script, mv command in android not work not linux. example, execute following command: adb shell mv "/system/app/books/" "/sdcard1/temp/debloat_bkp/system/app/books/" i following error: mv: invalid option -- p usage: mv [-fiv] source target mv [-fiv] source ... directory mv: /system/bin/cp: terminated 1 (non-zero) status have ideas why error , how solve problem? you need root directory/path , guess: /system/app/books/ https://stackoverflow.com/a/18935228/4409113 and not way though, use: backing android device using adb adb backup -apk -shared -all

html - Icon won't center align in button -

i have button set this: i cannot life of me icon sit in middle of button. this css: .buttonclass { width: 30px; height: 30px; border-radius: 20px; background-color: #1dbe60 } .iconclass { width: 20px; height: 20px; margin: 7.5px; } the caveat need margin on iconclass. here's plunk... http://plnkr.co/edit/6flyqlpfmddf7awenbtp?p=preview setting image background-image best bet. if can't create css rule .iconclass nested in .buttonclass since said cannot remove margin .iconclass directly. something this: .buttonclass .iconclass{ margin:0; position:absolute; top:50%; left:50%; transform:translate(-50%, -50%); } updated plunker .

python - Average of X*Y items and keeping dimensions of the numpy array -

how take average of example 4 nearby items (2*2) on 2 dimensional array? input is: [[1,1,1,1], [1,1,0,0], [0,0,1,1], [0,0,0,0]] which should result: [[1, 0.5], [0, 0.5]] numpy.mean(x.reshape(-1, 4), 1) flatten array , average 4 items in wrong order. additional info array produced example method: n = 10 l = 100 = np.zeros((l, l)) points = l*np.random.random((2, n**2)) a[(points[0]).astype(np.int), (points[1]).astype(np.int)] = 1 = ndimage.gaussian_filter(a, sigma=l/(4.*n)) here's 1 way reshaping , summing - m,n = a.shape a.reshape(m/2,2,n/2,2).sum(axis=(1,3))/4.0 of course, assumes number of rows , columns divisible 2 . sample run - in [87]: out[87]: array([[8, 4, 6, 8, 1, 1], [6, 7, 8, 5, 3, 4], [1, 8, 8, 4, 7, 6], [1, 8, 7, 7, 2, 4]]) in [88]: m,n = a.shape in [89]: a.reshape(m/2,2,n/2,2).sum(axis=(1,3))/4.0 out[89]: array([[ 6.25, 6.75, 2.25], [ 4.5 , 6.5 , 4.75]])

python - How do I make a code from this on pyscripter? Can anyone help me -

my algorithm this algorithm me coding i'm new , i'm sorry i'm not taught on subject. can learn soon typically, likes see you've tried. my suggestion put each of questions in function. here's simple code guide you: def question1(): answer = getanswer("question text") #fixme if answer: question5() else: question2() #etc #fixme: inputs... question1()

c - Macro result malfunction in an operation -

this question has answer here: the need parentheses in macros in c 8 answers i tried macro: #define min(x,y) x<y? x:y it's supposed return minimum , does. problem when trying use result of macro in operation, doesn't work. example x=min(3,4); here x naturally have 3 value, when trying this: x= 23 + min(3,4); the result still 3 (the result of macro), no matter number add (23 arbitrary in there). may know why happens? the problem operator assocativity , precedence. when expand macro, becomes: x = 23 + 3 < 4 ? 3 : 4; which interpreted as: x = (23 + 3) < 4 ? 3 : 4; because arithmetic has higher precedence comparison operators. should wrap expansion in parentheses force treated single expression. #define min(x,y) (x<y? x:y) you should put parenthese around uses of each parameter, in case they're expressions operat...

c++ - std::async([](){ std::cout<< "Hello "; }) build error -

cppcon 2015: detlef vollmann “executors c++ - long story ..." starts off example: std::async([](){ std::cout << "hello "; }); std::async([](){ std::cout << "world!\n"; }); c++ reference shows std::async in <future> , std::cout in <iostream> . missing make build work? $ cat >hw.cpp <<eof > #include <iostream> > int main(){ > std::cout << "hello world!\n"; > } > eof $ clang++ -std=c++14 hw.cpp $ ./a.out hello world! $ cat >cppcon15.cpp <<eof > #include <future> > #include <iostream> > int main(){ > std::async([](){ std::cout << "hello "; }); > std::async([](){ std::cout << "world!\n"; }); > } > eof $ clang++ -std=c++14 cppcon15.cpp /tmp/cppcon15-4f0a58.o: in function `std::thread::thread<std::__future_base::_async_state_impl<std::_bind_simple<main::$_1 ()>, void>::_async_state_imp...