Trending questions in Python

0 votes
1 answer

What are the ternary conditional operator in Python?

The Ternary Conditional operator was added in ...READ MORE

Sep 19, 2018 in Python by SDeb
• 13,300 points
566 views
0 votes
1 answer

In LightFM does the training set need to be the same size as the test set?

I would change the wording. Often in ML, ...READ MORE

Sep 21, 2018 in Python by charlie_brown
• 7,720 points
451 views
0 votes
1 answer

Determine the type of an object?

To get the type of an object, ...READ MORE

Sep 18, 2018 in Python by Priyaj
• 58,090 points
568 views
0 votes
1 answer

Python - abs vs fabs

math.fabs() converts its argument to float if it ...READ MORE

Sep 19, 2018 in Python by Priyaj
• 58,090 points
514 views
0 votes
1 answer

What is getattr() exactly and how do I use it?

You can view a full example here: http://www.diveintopython.net/power_of_introspection/index.html Introspection ...READ MORE

Sep 17, 2018 in Python by bug_seeker
• 15,520 points
593 views
0 votes
1 answer

Crawling after login in Python

You missed a few login data forms, ...READ MORE

Sep 14, 2018 in Python by Priyaj
• 58,090 points
718 views
+5 votes
1 answer

What are metaclasses in Python?

A metaclass instantiates and defines behavior for ...READ MORE

Sep 11, 2018 in Python by Priyaj
• 58,090 points
592 views
0 votes
1 answer

How to evaluate a soft Voting classifier being trained on some data

VotingClassifier does not have a best_score_ attribute. ...READ MORE

Sep 6, 2018 in Python by Priyaj
• 58,090 points
992 views
0 votes
1 answer

How to install Python MySQLdb module using pip?

It's easy to do, but hard to ...READ MORE

Aug 20, 2018 in Python by charlie_brown
• 7,720 points
1,709 views
0 votes
1 answer

How to find index from raw and column in python?

You probably want to use np.ravel_multi_index: import numpy as ...READ MORE

Sep 12, 2018 in Python by Priyaj
• 58,090 points
672 views
0 votes
1 answer

Python while sampling

I would say, this could be your ...READ MORE

Sep 20, 2018 in Python by Priyaj
• 58,090 points
336 views
0 votes
1 answer

How is Python 2.7.3 and Python 3.3 different?

raw_input() is not used in Python 3. Use input()  ...READ MORE

Sep 12, 2018 in Python by SDeb
• 13,300 points
668 views
0 votes
1 answer

SKLearn NMF Vs Custom NMF

The choice of the optimizer has a ...READ MORE

Sep 14, 2018 in Python by Priyaj
• 58,090 points
560 views
0 votes
1 answer

Avoid killing children when parent process is killed

I would recommend against your design as ...READ MORE

Sep 14, 2018 in Python by Priyaj
• 58,090 points
557 views
0 votes
1 answer

Creating a new dict in Python

Call dict with no parameters new_dict = dict() or simply write new_dict ...READ MORE

Sep 17, 2018 in Python by Priyaj
• 58,090 points
405 views
0 votes
1 answer

Pyomo parallel processing to solve an instance

Depends on the solver and the model. ...READ MORE

Sep 11, 2018 in Python by Priyaj
• 58,090 points
649 views
0 votes
1 answer

Balanced binary tree python

Instead of multiplying the number of nodes ...READ MORE

Sep 12, 2018 in Python by Priyaj
• 58,090 points
583 views
+1 vote
1 answer

Why does x,y = zip(*zip(a,b)) work in Python?

I'm extremely new to Python so this ...READ MORE

Aug 23, 2018 in Python by Priyaj
• 58,090 points
1,369 views
0 votes
1 answer

Make a unix alias with python script

The scope of an alias command is the shell ...READ MORE

Sep 10, 2018 in Python by Priyaj
• 58,090 points
620 views
0 votes
1 answer

OSX 10.11 with py2app?

Try this: In the directory of Sandwich.py (or ...READ MORE

Sep 6, 2018 in Python by Priyaj
• 58,090 points
763 views
0 votes
0 answers

Boolean comparison in Python

I am trying to print false using ...READ MORE

Sep 17, 2018 in Python by ana1504.k
• 7,910 points
326 views
0 votes
1 answer

How can I expose callbacks to Fortran using Python

The code that I've written below. The ...READ MORE

Aug 24, 2018 in Python by aryya
• 7,450 points
1,343 views
0 votes
1 answer

GAE: python code to check if i'm on dev_appserver or deployed to appspot

I don't know if you still need ...READ MORE

Sep 11, 2018 in Python by anonymous
624 views
0 votes
1 answer

Comparing two files contents in python

Considering your file "Unique.txt" does just containt the IP ...READ MORE

Sep 11, 2018 in Python by Priyaj
• 58,090 points
516 views
0 votes
1 answer

setuptools: build shared libary from C++ code, then build Cython wrapper linked to shared libary

There is a seemingly undocumented feature of setup that ...READ MORE

Sep 11, 2018 in Python by Priyaj
• 58,090 points
495 views
0 votes
1 answer

Difference between append vs. extend list methods in Python

append: Appends object at the end. x = ...READ MORE

Aug 8, 2018 in Python by bug_seeker
• 15,520 points
1,962 views
0 votes
1 answer

How to create transaction in GnuCash in response to an email?

Here's a template, along with a couple ...READ MORE

Sep 5, 2018 in Python by Priyaj
• 58,090 points
744 views
0 votes
1 answer

Python: nested 'for' loops

Could use itertools: >>> for comb in itertools.combinations_with_replacement(range(9, -1, ...READ MORE

Sep 3, 2018 in Python by Priyaj
• 58,090 points
819 views
0 votes
1 answer

Need help with Tkinter window formatting using Python

Tkininter comes with the columnspan argument to span the labels ...READ MORE

Sep 7, 2018 in Python by aryya
• 7,450 points
631 views
0 votes
1 answer

Avoiding multiple nested for-loops in python

You can replace the three loops with: from ...READ MORE

Sep 7, 2018 in Python by Priyaj
• 58,090 points
625 views
0 votes
1 answer

How can I rename files on the fly using Python?

You could simply use a wrapper object ...READ MORE

Sep 7, 2018 in Python by aryya
• 7,450 points
595 views
0 votes
1 answer

Python while sampling

From guessing I would say, this could ...READ MORE

Sep 10, 2018 in Python by Priyaj
• 58,090 points
438 views
+1 vote
1 answer

How to print an error in Python?

For Python 2.6 and later and Python ...READ MORE

Aug 23, 2018 in Python by Priyaj
• 58,090 points
1,163 views
+1 vote
3 answers

What are the ways of detecting outliners in Python

code from http://eurekastatistics.com/using-the-median-absolute-deviation-to-find-outliers  This uses the L1 distance ...READ MORE

Aug 24, 2018 in Python by eatcodesleeprepeat
• 4,710 points

reshown Aug 24, 2018 by Priyaj 994 views
0 votes
1 answer

How to implement Hashmaps in Python

Python dictionary is a built-in type that supports ...READ MORE

Aug 31, 2018 in Python by charlie_brown
• 7,720 points
788 views
0 votes
1 answer

How to Print a List in Python

ou are using Python 2.x syntax with ...READ MORE

Aug 31, 2018 in Python by charlie_brown
• 7,720 points
784 views
0 votes
1 answer

Is there a foreach function in python and is there a way to implement it if there isnt any

Every occurence of "foreach" I've seen (PHP, ...READ MORE

Aug 31, 2018 in Python by charlie_brown
• 7,720 points
782 views
0 votes
1 answer

Getting some errors regarding python when using sublime text

I don't know if you still need ...READ MORE

Sep 8, 2018 in Python by charlie_brown
• 7,720 points
461 views
0 votes
1 answer

SKLearn NMF Vs Custom NMF

The choice of the optimizer has a ...READ MORE

Sep 7, 2018 in Python by Priyaj
• 58,090 points
457 views
+1 vote
1 answer

What is the function for Factorial in Python

Easiest way: math.factorial(x) (available in 2.6 and ...READ MORE

Aug 21, 2018 in Python by Priyaj
• 58,090 points

edited Aug 21, 2018 by Omkar 1,119 views
0 votes
1 answer

Modify int in place

Use a list rather than a tuple: my_container ...READ MORE

Sep 7, 2018 in Python by Priyaj
• 58,090 points
379 views
0 votes
1 answer

How to create new folder?

You can create a folder with os.makedirs() and use os.path.exists() to ...READ MORE

Sep 3, 2018 in Python by Priyaj
• 58,090 points
542 views
0 votes
1 answer

Python ctypes segmentation fault when rootfs is read-only and /tmp is noexec

I cant really seem to reproduce the ...READ MORE

Aug 28, 2018 in Python by anonymous
807 views
+1 vote
1 answer

How to append an integer to a string?

You can not directly concatenate two different ...READ MORE

Aug 16, 2018 in Python by Omkar
• 69,210 points
1,241 views
+1 vote
1 answer

How to write the Fibonacci Sequence?

Efficient Pythonic generator of the Fibonacci sequence I ...READ MORE

Aug 21, 2018 in Python by Priyaj
• 58,090 points
1,016 views
0 votes
2 answers

How to create new folder?

import os try: os.makedirs(path) except ...READ MORE

Aug 31, 2018 in Python by Omkar
• 69,210 points
616 views
0 votes
1 answer

How can I reformat value_counts() analysis in Pandas for large number of columns?

If I were you, I'd do it ...READ MORE

Apr 17, 2018 in Python by anonymous
6,455 views
0 votes
1 answer

Linux command-line call not returning what it should from os.system?

What gets returned is the return value ...READ MORE

Aug 29, 2018 in Python by Priyaj
• 58,090 points
655 views
0 votes
1 answer

Python class inherits object

Python 3.x: class MyClass(object): = new-style class class MyClass: = new-style ...READ MORE

Aug 30, 2018 in Python by Priyaj
• 58,090 points
600 views
0 votes
1 answer

Examples for string find in Python

you can use str.index too: >>> 'sdfasdf'.index('cc') Traceback ...READ MORE

Aug 29, 2018 in Python by Priyaj
• 58,090 points
593 views