Most answered questions in Python

+2 votes
4 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,520 points
119,801 views
0 votes
3 answers

How to split a string into a list?

Using For loop This approach uses for loop ...READ MORE

Jan 4, 2021 in Python by David Samon
714 views
0 votes
3 answers

How do I use raw_input in Python 3?

raw_input() was renamed to input() in Python 3. Another example ...READ MORE

Jan 4, 2021 in Python by Carlos
2,766 views
0 votes
3 answers

How to add a new item to a dictionary in Python?

There is no add() , append() , or insert() method ...READ MORE

Jan 4, 2021 in Python by Reshma
580 views
0 votes
3 answers

TypeError: 'module' object is not callable

Solve By Calling with Module Name Another solution to the TypeError: 'module' object ...READ MORE

Jan 4, 2021 in Python by Carlos
34,639 views
0 votes
3 answers

How can I sort a dictionary by key in python?

Another way could be: color_dict = {'red':'#FF0000',           'green':'#008000',           'black':'#000000',           'white':'#FFFFFF'} for ...READ MORE

Dec 28, 2020 in Python by Thomas Walenta
841 views
0 votes
3 answers

How do I find the location of my Python site-packages directory?

Configuring Python to use additional locations for ...READ MORE

Dec 28, 2020 in Python by Nikita
87,750 views
0 votes
3 answers

Best way to convert string to bytes in Python?

We can use the built-in Bytes class in Python ...READ MORE

Dec 28, 2020 in Python by David Samon
29,981 views
0 votes
3 answers

Count the number occurrences of a character in a string

The string count() method returns the number of occurrences of ...READ MORE

Dec 28, 2020 in Python by Carlos
13,414 views
0 votes
3 answers

Is there a simple way to delete a list element by value?

There are three ways in which you ...READ MORE

Dec 28, 2020 in Python by Thomas Walenta
507 views
+1 vote
3 answers

While using pyttsx 3 , I am having the following ERROR, i have installed pypiwin32

Try this: pip uninstall pyttsx3 Then: pip install pyttsx3==2.71 READ MORE

Aug 12, 2020 in Python by Eghosa
7,133 views
0 votes
3 answers
0 votes
3 answers

AttributeError: 'numpy.ndarray' object has no attribute 'append'

for root, dirs, files in os.walk(directory): ...READ MORE

Dec 12, 2020 in Python by Rajiv
• 8,910 points
52,189 views
0 votes
3 answers

Command "python setup.py egg_info" failed with error code 1 in C:\Users\Nadeem\AppData\Local\Temp\

You have an out of date version ...READ MORE

Dec 15, 2020 in Python by Rajiv
• 8,910 points
37,141 views
0 votes
3 answers

import NumPy as np ImportError: No module named NumPy

You need to install numpy using pip install ...READ MORE

Dec 16, 2020 in Python by Roshni
• 10,520 points
35,136 views
+2 votes
3 answers

ModuleNotFoundError: No module named 'cv2'

Hi@akhtar, This error may occur if you didn't install ...READ MORE

Apr 9, 2020 in Python by MD
• 95,440 points
266,564 views
0 votes
3 answers

i am installing wordcloud using pip but i am unable to do that ....i am getting the following error

word cloud is not supported for python ...READ MORE

Apr 15, 2020 in Python by anonymous
31,911 views
0 votes
3 answers

(unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape

You are getting this error because you ...READ MORE

Dec 31, 2019 in Python by Kalgi
• 52,360 points
99,006 views
+1 vote
3 answers

AttributeError: 'module' object has no attribute 'listen"

You'll have to install the pyaudio module ...READ MORE

Oct 3, 2019 in Python by Liala
6,176 views
+2 votes
3 answers

ModuleNotFoundError: No module named 'Crypto'

The module you’ve installed is different. To install ...READ MORE

Aug 20, 2019 in Python by Raman
77,701 views
0 votes
3 answers

How to distinguish between a variable and an identifier?

An identifier actually identifies something, it's not the thing ...READ MORE

Dec 16, 2020 in Python by Rajiv
• 8,910 points
60,998 views
+1 vote
3 answers

How do I share global variables across modules? - python

The best way to share global variables ...READ MORE

Jul 24, 2019 in Python by Faiza
134,933 views
+4 votes
3 answers

Write a for loop that prints all elements of a list and their position in the list. a = [4,7,3,2,5,9]

Try using this question by list comprehension: a=[4,7,3,2,5,9] print([x for ...READ MORE

Dec 9, 2019 in Python by vinaykumar
• 200 points
33,897 views
0 votes
3 answers

How to replace negative numbers in Pandas Data Frame by zero?

 If all your columns are numeric, you ...READ MORE

Dec 16, 2020 in Python by Rajiv
• 8,910 points
43,158 views
0 votes
3 answers

Pandas - FillNa with another column

You could do df.Cat1 = np.where(df.Cat1.isnull(), df.Cat2, df.Cat1 ...READ MORE

Dec 15, 2020 in Python by Roshni
• 10,520 points
84,011 views
0 votes
3 answers

How to draw a tic tac toe board in python?

def printTable():             for i in range(1,10):                     print(" ",end=' ')                     if(i%3==0 ...READ MORE

Oct 11, 2020 in Python by Sumit Nagpal
11,026 views
+1 vote
3 answers

Python error "AttributeError: 'Turtle' object has no attribute 'Shape'"

Hey @Nagya, replace python.Shape("Square") with the following: python.shape("square") Python is case ...READ MORE

Jun 19, 2019 in Python by Faiza
21,079 views
0 votes
3 answers

TypeError: unsupported operand type(s) for -: 'str' and 'str'

& is "bitwise and" operand in Python, you ...READ MORE

Dec 11, 2020 in Python by Rajiv
• 8,910 points
79,495 views
+1 vote
3 answers

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

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

Apr 8, 2019 in Python by Kunal
146,564 views
0 votes
3 answers

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

It is not working because your code ...READ MORE

May 13, 2020 in Python by anonymous

edited May 13, 2020 by Gitika 50,748 views
0 votes
3 answers

Python Pandas: ValueError: DataFrame constructor not properly called!

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

Mar 28, 2019 in Python by Ritu
84,770 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, 2019 in Python by Alok
48,488 views
+1 vote
3 answers

How to print one pandas column without index?

There is a slight mistake in what ...READ MORE

Mar 28, 2019 in Python by Shri
62,650 views
0 votes
3 answers

Is python version 3.7.2 supported by pycharm jetbrains IDE?

Yes it works fine.. READ MORE

Feb 28, 2019 in Python by Pratosh kumar
1,109 views
0 votes
3 answers

Python program to print occurrence of character in string

Try below code string = input("Enter a string: ...READ MORE

May 28, 2020 in Python by Anubhav
• 300 points
29,811 views
0 votes
3 answers

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

FWIW, the multiprocessing module has a nice interface for ...READ MORE

Dec 15, 2020 in Python by Roshni
• 10,520 points
105,434 views
+1 vote
3 answers

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

Hey. You have to use SpeechRecognition as module ...READ MORE

Nov 28, 2018 in Python by Omkar
• 69,210 points
40,160 views
0 votes
3 answers

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

NameError: name 'xx' is not defined Python knows ...READ MORE

Mar 19, 2020 in Python by rahul
• 360 points
41,440 views
+1 vote
3 answers

PYTHON: Who could help?

A quick solution is to use the collections ...READ MORE

Nov 26, 2018 in Python by Omkar
• 69,210 points
653 views
+1 vote
3 answers

How can I remove duplicate dict in list in Python?

[dict(t) for t in {tuple(d.items()) for d ...READ MORE

Aug 15, 2019 in Python by anonymous

edited Aug 20, 2019 by Kalgi 8,984 views
+1 vote
3 answers

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
93,376 views
0 votes
3 answers

What is the python keyword “with” used for?

The with statement in Python simplifies exception ...READ MORE

Jul 19, 2019 in Python by rahul
• 360 points
1,207 views
0 votes
3 answers

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

The functions* quit(), exit(), and sys.exit() function in the same way: ...READ MORE

Dec 14, 2020 in Python by Gitika
• 65,910 points
66,060 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 996 views
0 votes
3 answers

'python' is not recognized as an internal or external command

Try "py" instead of "python" from command line: C:\Users\Cpsa>py Python 3.4.1 (v3.4.1:c0e311e010fc, May ...READ MORE

Feb 8, 2022 in Python by Rahul
• 9,670 points
2,126 views
+1 vote
3 answers

How to run the Python program forever?

you can also do the old fashioned ...READ MORE

Jun 10, 2019 in Python by brianno
20,184 views
0 votes
3 answers

How to get the current time in Python

FOLLOWING WAY TO FIND CURRENT TIME IN ...READ MORE

Apr 8, 2019 in Python by rajesh
• 1,270 points
1,716 views
0 votes
3 answers

how to use print statement in python3?

Brackets are required to print the output. >>> ...READ MORE

Nov 25, 2021 in Python by anonymous
1,334 views
+1 vote
3 answers

Difference between append vs. extend list methods in Python

Python append() method adds an element to ...READ MORE

Aug 21, 2019 in Python by germyrinn
• 240 points
95,787 views