Hello people, I'm currently working on a python module providing tools for co-workers to use and some of the functions I'm trying to provide can return quite a bit of useful information (say, 5 return values), but in most use case, only the first two
I am very new to scraping, so as I understand, BeautifulSoup only extracts the data found inside tags (with functions like get, find, find_all ...) The source code of the website i am scraping is displaying the various items inside the same tag and t
I've never seen anything else work like this before. Is there anything else that does this? >>> class NothingSpecial: @classmethod def meth(cls): pass >>> NothingSpecial.meth <bound method classobj.meth of <class __main__.NothingSp
I would like create authentication in Django. I'm trying to do everything according to this. Unfortunately, at this moment I have two problems. Firstly, when I try to add from rest_framework.authtoken import views I have conflict with from companies
I'm trying to implement Binary Search tree in python using recursion. I got trapped in some infinite recursions happening in my program.I'm making recursive calls to the function RecursBST by passing address and the data until the top traverse down t
This question already has an answer here: Recursive function returning none in Python [duplicate] 2 answers python recursion return None type 2 answers Return in Recursive Function 3 answers Python recursion and return statements 2 answers Can't figu
base = (.75) hood = (.70) pipeAura = (.9) cloak = (.85) glimmer = (.85) null = (.78) heap = (.88) corrosive = (.75) spiritBear = (.67) spellShield = (.5) berserkersBlood = (.5) pipe = hood * pipeAura antimage = spellShield * base viper = corrosive *
I have a pandas dataframe df which contains a column amount. For many rows, the amount is zero. I want to randomly remove 50% of the rows where the amount is zero, keeping all rows where amount is nonzero. How can I do this?pandas Using query + sampl
class student(object): def __init__(self, name, age, year): self.name, self.age, self.year = name, age, year self.grades=[] self.grade={} print(name,'-------->','Age:',age,'','Year:',year) def set_grades(self,score): self.grades.append(score) def get
I am new to Python, can anyone please point out the mistake, i have made in the code: numlist = [3,2,5,5,7,6,1,8,4] def peaks(numlist): exceed = [] for elem in numlist: for num in exceed: if elem not in exceed: if num in exceed < elem in numlist: exc
I am brand new to programming and am working through the "Automate the Boring Stuff" book for Python 3. I've seen several other people with questions on the 'Comma Code' project but not my specific problem. I have come up with a 'working' bit to
This question is close to what is asked in Overriding other __rmul__ with your class's __mul__ but I am under the impression that this is a more general problem then only numerical data. Also that is not answered and I really don't want to use the ma
Let's say I have a 1D numpy array x and another one y = x ** 2. I am looking for an easier alternative to for i in range(x.size): print(x[i], y[i]) With one array one can do print(*x, sep = '\n') which is easier than a for loop. I'm thinking of somet
I have a multiprocessing program where one process adds elements to a shared list (multiprocessing.Manager().list()) several other processes consume these elements from that list (and remove them); they run until there is something to process in the
This question already has an answer here: How do you remove duplicates from a list in whilst preserving order? 33 answers I have a problem in my code where I have the following: import random Probabilities={'AA':0.2,"TT":0.2, "GG":0.1,
I have to split a text file into a specific amount of words per list in list, probably be best to show in example. say the text file looks like this "i am having a good day today" i have to write a function which looks like this ngrams.makeNGram
Picture a 4x4 grid in a tkinter window. I want to expand the cell at row 2, column 2 but not everything else on row 2 or column 2. Im designing a text window with selectable options on the left side in rows 1-15. Making row 2 with weight 1 and column
I installed python 3.5.1 via ampps and it's working. However, when i try to use pip, i get the following message: Fatal error in launcher: Unable to create process using '"' I already reinstalled ampps into a path which doesn't include any whitespace
So I have this script (running Python 3.5) using Google API and Newspaper. It searches google for articles that have to do with sleep. And then using Newspaper, I iterate over those URLS. And all I'm asking Newspaper to do is return a list of keyword
I have a list which grows and shrinks in a for loop. The list looks like following :- . With every element inside list of list i want to associate it to a separate dictionary. list123 = [[1010,0101],[0111,1000]] In this case I want to create 4 dictio
As I understand, | tries different subpatterns in alternation and matches the first possible option. Whenever there are multiple groups, the later ones behave unexpectedly when one of the subpatterns is empty giving it priority. Example: re.search("(
This question already has an answer here: CSV file written with Python has blank lines between each row 5 answers Im having a hard time trying to delete empty(blank) rows from a csv file using python 3.4.3. Each time I run my script the output remain
I've dabbled a little bit in Python - not much beyond modifying other people's scripts. Now I'm considering getting into it for real, and have hit the "Choose whether to learn 3.x or 2.x" dilemma. I've read that the main issue with 3.x is the ex
Note: I've done edits to the dataset that I think will work better for calculating the average. My data look like this: [[2015, 0.23, 0.45, 1.23], [2014, 1.22, 2.54, 0.98], [2013, 0.33, 2.11, 0.43], ...] Where the data are now lists within a list. Th
I have this code: def __executeCommand(self, command: str, input: str = None) -> str: p = sub.Popen(command, stdout=sub.PIPE, stderr=sub.PIPE, stdin=sub.PIPE, universal_newlines=True) p.stdin.write(input) output, error = p.communicate() if (len(error
Could there possibly be hidden files that I would need to find. Or do I have to re-install Python 2.7 if I want to work with it? ThanksPython installations on OS X generally go in separately and don't uninstall each other. Also, the convention is sti
I am trying to provide a recursive method that provides a list of all the possible combinations when given a list of courses. E.g course = [Entree, Dessert] This is what I have so far: Entree = ["pumkinsoup","antipasto"] Dessert = [&qu
In my Python script, I need to create a new file in a sub directory without changing directories, and I need to continually edit that file from the current directory. My code: os.mkdir(datetime+"-dst") for ip in open("list.txt"): with
I am in a class teaching python and am a beginner at any sort of coding. I keep running into this problem and I can't find anything in my text book or additional handouts explaining what I'm doing wrong. Here is an example taken from one of the exerc
I get this error when trying to take an integer and prepend "b" to it, converting it into a string: File "program.py", line 19, in getname name = "b" + num TypeError: Can't convert 'int' object to str implicitly That's relate