Pandas - return n smallest indexes by column

I have the following (simplified) dataframe: df = pd.DataFrame({'X': [1, 2, 3, 4, 5,6,7,8,9,10], 'Y': [10,20,30,40,50,-10,-20,-30,-40,-50], 'Z': [20,18,16,14,12,10,8,6,4,2]},index=list('ABCDEFGHIJ')) Which gives the following: X Y Z A 1...
more »

2017-07-19 16:07 (3) Answers

Error when importing webdriver from selenium

I'm trying to get all results from a predefined google search, but I'm stuck at the following error: Traceback (most recent call last): File "C:\python36\lib\site-packages\selenium\webdriver\common\service.py", line 74, in start stdout=self.log_f...
more »

2017-07-19 11:07 (0) Answers

Is there a mutable String gem in Python?

As I understand it, basic strings in python are immutable, as in LISP, and not as in, say Python/TCL/Ruby, where one can modify it many times w/o incurring the schlemiel painter algorithm My question: Is there a Python gem to achieve the same? I coul...
more »

2017-07-19 11:07 (0) Answers

Use sphinx to generate c++ documentation

I'm working on a python and C++ project and want to generate a global html documentation. For the python part I already setup sphinx to generate the documentation. This is working like a charm. But now there comes the C++ part. First I installed br...
more »

2017-07-19 09:07 (0) Answers

Error in systemd service in linux (Ubuntu)

I am trying to create service in Ubuntu but I am getting error. I wrote below code- In FileSystemWatcher.py import requests import json import logging import sys import os import datetime from watchdog.events import PatternMatchingEventHandler ...
more »

2017-07-19 08:07 (1) Answers

Search two byte with in a string in python

I have a string like the following: \x31\xc0\xb8\x04\x00\x00\x00\x31\xdb\xb3\x01\x31\xd2\x52\x68\x72\x6c\x64\x0a\x68\x6f\x20\x57\x6f\x68\x48\x65\x6c\x6c\x89\xe1\xb2\x0c\xcd\x80\xb0\x01\xb3\x02\xcd\x80 I search it for null bytes with following code. ...
more »

2017-07-18 17:07 (2) Answers

Initialize transposed numpy array

I want to use the Singular-Value-Decomposition of matrix A. If possible I would write: V, S, W.T = np.linalg.svd(A) But I can't initialise an array with its transposed. Now I have two questions: As far as I understand the python internals ther...
more »

2017-07-18 14:07 (1) Answers

Python - Extract information from dataframe (JSON)

I'm a begginer and it's been a long time I didn't code anything :-) I'm using requests library to retrieve JSON data from the Incapsula(Cloud web security service) API to get some stats about a website. What I want in the end is to write the "type of...
more »

2017-07-18 14:07 (1) Answers

python re for validation string

Below is code: import re string = "02:222222" if re.match(r'[a-fA-F0-9]+[a-fA-F0-9]+:+[a-fA-F0-9]+[a-fA-F0-9]+$',string): print "pass" else: print "fail" above code is printing "pass" my expected output should be "fail" Below are the fe...
more »

2017-07-18 07:07 (3) Answers