Most viewed questions in Python

+2 votes
11 answers

How to print array/ list without brackets in python?

print(*names, sep = ', ') This is what ...READ MORE

Dec 10, 2018 in Python by Sudo
19,764 views
+2 votes
5 answers

What exactly is the function of random.seed() in python?

The seed method is used to initialize the ...READ MORE

Oct 29, 2018 in Python by Rahul
15,197 views
0 votes
1 answer

How can I use python to execute a curl command?

For sake of simplicity, maybe you should ...READ MORE

Oct 11, 2018 in Python by charlie_brown
• 7,720 points
12,838 views
0 votes
1 answer

How to fix this? ValueError: invalid literal for int() with base 10 error in Python

The following are totally acceptable in python: passing ...READ MORE

Nov 16, 2018 in Python by Nymeria
• 3,520 points
9,576 views
0 votes
11 answers
0 votes
1 answer

How to get the return value from a thread using python?

You don't need to change your existing ...READ MORE

Dec 3, 2018 in Python by Nymeria
• 3,520 points

edited Dec 19, 2018 by Nymeria 8,679 views
0 votes
2 answers

Extracting data from a JSON file in Python

Here is what i found and was ...READ MORE

Nov 27, 2018 in Python by Rupali
6,799 views
0 votes
1 answer

How do you add a background thread to flask in Python?

The example below creates a background thread ...READ MORE

Nov 19, 2018 in Python by Nymeria
• 3,520 points
5,901 views
0 votes
1 answer

How can I check for NaN in Python?

math.isnan() Checks if the float x is a ...READ MORE

Aug 16, 2018 in Python by Priyaj
• 56,520 points
5,830 views
+1 vote
3 answers

What do you mean by python scripting? What is a script and a module in python?

A module is a file containing a ...READ MORE

Jun 17 in Python by Zain Abbas
5,039 views
+2 votes
2 answers

How can I replace values with 'none' in a dataframe using pandas

Actually in later versions of pandas this ...READ MORE

Aug 13, 2018 in Python by bug_seeker
• 15,350 points
4,905 views
0 votes
1 answer

How to convert a Pandas GroupBy object to DataFrame in Python

g1 here is a DataFrame. It has a hierarchical index, ...READ MORE

Nov 12, 2018 in Python by Nymeria
• 3,520 points
4,687 views
+1 vote
4 answers

How to write nested dictionaries to a CSV file

Using DictWriter there is no need in ...READ MORE

Oct 18, 2018 in Python by Richard William
4,271 views
+4 votes
7 answers

Splitting a List into chunks in Python

Here's a generator that yields the chunks ...READ MORE

Apr 13, 2018 in Python by Nietzsche's daemon
• 4,260 points
4,103 views
0 votes
2 answers

Manually raising (throwing) an exception in Python

Exception handling issues in python can easily ...READ MORE

Jan 18 in Python by nick
• 140 points
3,997 views
0 votes
2 answers

Python error "NameError: name 'sr' is not defined"

Did you import the module? READ MORE

Jun 4 in Python by anonymous
3,783 views
0 votes
1 answer

How to install tkinter in pycharm?

Ya, this is a problem with installing ...READ MORE

Apr 3 in Python by Jishan
3,550 views
0 votes
2 answers

How do play audio (playsound) in background of Python script?

There’s an optional second argument, block, which ...READ MORE

Jun 7 in Python by anonymous
2,854 views
0 votes
1 answer

ProgrammingError: not all arguments converted during string formatting

Sorted!!!! just found the solution, 1 - apparently ...READ MORE

Sep 10, 2018 in Python by Priyaj
• 56,520 points
2,596 views
+1 vote
2 answers

Measuring the distance between pixels on OpenCv with Python

You can try this: Mat pts1(nPts, 1, CV_8UC2), ...READ MORE

Aug 24, 2018 in Python by Omkar
• 67,290 points
2,576 views
0 votes
1 answer

Python Pandas: ValueError: DataFrame constructor not properly called!

The syntax is not right. The right ...READ MORE

Mar 28 in Python by Ritu
2,556 views
0 votes
2 answers

Not able to install speech_recognition in python: ModuleNotFoundError: No module named 'speech_recognition'

The pip library is called SpeechRecognition, not ...READ MORE

Jan 24 in Python by anonymous
2,401 views
0 votes
1 answer

How can I use grep in Python?

First of all, you are not iterating ...READ MORE

Dec 12, 2018 in Python by charlie_brown
• 7,720 points
2,325 views
+3 votes
1 answer

Tensorflow 1.5 ImportError: No module named tensorflow.python.client

I think it's a bug in Tensorflow ...READ MORE

Sep 25, 2018 in Python by charlie_brown
• 7,720 points
2,267 views
0 votes
1 answer

How to change/update cell value in Python Pandas dataframe?

You can use the at() method to ...READ MORE

Apr 8 in Python by Kunal
2,263 views
+1 vote
1 answer

How to check if a string is null in python

Try this: if cookie and not cookie.isspace(): # the ...READ MORE

Aug 20, 2018 in Python by Priyaj
• 56,520 points
2,238 views
0 votes
1 answer

Flask App Using WTForms with SelectMultipleField

Flask returns request.form as a werkzeug MultiDict ...READ MORE

Aug 22, 2018 in Python by ariaholic
• 7,340 points
2,210 views
0 votes
1 answer

Python Pandas error: AttributeError: 'DataFrame' object has no attribute 'rows'

There is no attribute called “rows”. The ...READ MORE

Mar 28 in Python by Shri
2,173 views
0 votes
1 answer

1 Year Rolling mean pandas on column date

I believe this should work for you: # ...READ MORE

Sep 6, 2018 in Python by Priyaj
• 56,520 points
2,050 views
0 votes
2 answers

Python pandas: TypeError: Index(...) must be called with a collection of some kind, 'Email' was passed

Try: df1=pd.DataFrame(columns=['Email']) READ MORE

May 19 in Python by anonymous
2,012 views
0 votes
1 answer

How to open another window using PyQt

Switch between self.hide() and self.showMinimized() def start(self): ...READ MORE

Oct 1, 2018 in Python by Priyaj
• 56,520 points
1,960 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
1,919 views
0 votes
1 answer

Python exit commands - why so many and when should each be used?

Let me give some information on them: quit ...READ MORE

Aug 27, 2018 in Python by Priyaj
• 56,520 points
1,914 views
+2 votes
1 answer

How to install pip in windows?

Step 1:  Open the following link and go to ...READ MORE

Nov 27, 2018 in Python by Priyaj
• 56,520 points
1,900 views
0 votes
1 answer

How do you get the logical xor of two variables in Python?

If you're already normalizing the inputs to ...READ MORE

May 29, 2018 in Python by ariaholic
• 7,340 points
1,859 views
0 votes
1 answer

Python convert XLS and XLSX file to csv

You can't convert the files with both ...READ MORE

Feb 8 in Python by Omkar
• 67,290 points
1,822 views
0 votes
3 answers

Python pandas: TypeError: tuple indices must be integers or slices, not str

In fact, I get a perfectly good ...READ MORE

Jun 13 in Python by Alok
1,674 views
0 votes
1 answer

How to convert datetime.date to UTC timestamp in Python

In Python 3 (< 3.3) From the docs ...READ MORE

Oct 31, 2018 in Python by Priyaj
• 56,520 points
1,647 views
0 votes
1 answer

How can I write code to find a palindrome in python without using string functions?

In Logic 1, try if i<int(length/2): instead of if i<int((length/2+1)): In ...READ MORE

Jan 16 in Python by charlie_brown
• 7,720 points
1,638 views
0 votes
1 answer

How to print first character of each word in upper case of a string in Python

You can use split() using space as ...READ MORE

Jun 1, 2018 in Python by george
• 200 points
1,583 views
0 votes
1 answer

Convert HTML to an image in Python

webkit2png. The original version is OSX-only, but luckily ...READ MORE

Feb 4 in Python by SDeb
• 13,160 points
1,579 views
+1 vote
1 answer

How to handle Real-Time Matplotlib Plotting

To draw a continuous set of random ...READ MORE

Sep 26, 2018 in Python by Priyaj
• 56,520 points
1,570 views
0 votes
1 answer

In Python, what is difference between Array and List?

Lists and arrays are used in Python ...READ MORE

Mar 15 in Python by Taj
• 1,040 points

edited Mar 18 by Omkar 1,554 views
0 votes
1 answer

How to sort Counter by value using python?

Use the Counter.most_common() method, it'll sort the items for you: >>> ...READ MORE

May 22, 2018 in Python by charlie_brown
• 7,720 points
1,544 views
+2 votes
3 answers

How can I play an audio file in the background using Python?

down voteacceptedFor windows: you could use  winsound.SND_ASYNC to play them ...READ MORE

Apr 3, 2018 in Python by charlie_brown
• 7,720 points
1,538 views
0 votes
1 answer

how to exit a python script in an if statement

This works fine for me: while True: ...READ MORE

Sep 19, 2018 in Python by bug_seeker
• 15,350 points
1,523 views
0 votes
1 answer

text = _whitespace_only_re.sub('', text) TypeError: expected string or bytes-like object

This seems like an issue with textwrap ...READ MORE

Feb 13 in Python by Omkar
• 67,290 points
1,513 views
0 votes
1 answer

Pyplot error "only size-1 arrays can be converted to Python scalars"

You can plot the chart by taking ...READ MORE

Jan 28 in Python by Omkar
• 67,290 points
1,468 views
0 votes
1 answer

What is the difference between list and tuple?

Lists are mutable(values can be changed) whereas ...READ MORE

May 4, 2018 in Python by aayushi
• 750 points
1,405 views
0 votes
1 answer

Open multiple files using with open() in Python?

Just replace and with , and you're done: with open('a', 'w') as ...READ MORE

Oct 31, 2018 in Python by Priyaj
• 56,520 points
1,399 views