Most viewed questions in Python

0 votes
1 answer

ModuleNotFoundError: No module named 'mysql'

Hi@akhtar, You need to install mysql-connector to connect ...READ MORE

Jul 15, 2020 in Python by MD
• 95,440 points
49,336 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,418 views
0 votes
1 answer

/usr/bin/env: ‘python’: No such file or directory

Hi@akhtar, It seems your python script is not ...READ MORE

Sep 20, 2020 in Python by MD
• 95,440 points
47,238 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,088 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,376 views
0 votes
1 answer

TypeError: 'float' object cannot be interpreted as an integer

Hi, @There, The “TypeError: ‘float’ object cannot be ...READ MORE

Nov 13, 2020 in Python by Gitika
• 65,910 points
41,255 views
0 votes
1 answer

How do I install the yaml package for Python?

Hello @kartik, You could try the search feature ...READ MORE

May 12, 2020 in Python by Niroj
• 82,880 points
40,861 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,060 views
0 votes
1 answer

KeyError: "['Place'] not found in axis"

Hi@akhtar, You need to provide the axis parameter ...READ MORE

Jun 24, 2020 in Python by MD
• 95,440 points
40,015 views
0 votes
1 answer

How to convert BeautifulSoup object to string?

You can do this by directly type ...READ MORE

Apr 4, 2019 in Python by Ashu
37,564 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,115 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,560 points
36,245 views
+1 vote
1 answer

How to get the currently logged in user's user id in Django?

Hello @kartik, First make sure you have SessionMiddleware and AuthenticationMiddleware middlewares added ...READ MORE

Aug 12, 2020 in Python by Niroj
• 82,880 points
35,811 views
+1 vote
8 answers

Count the frequency of an item in a python list

To count the number of appearances: from collections ...READ MORE

Oct 18, 2018 in Python by tinitales
35,239 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,121 views
0 votes
1 answer

Error:django MultiValueDictKeyError

Hello @kartik, Use the MultiValueDict's get method. This is also ...READ MORE

May 20, 2020 in Python by Niroj
• 82,880 points
35,084 views
0 votes
1 answer

Python: Could not install packages due to an OSError: [Errno 2] No such file or directory

I also met with the same problem ...READ MORE

Apr 28, 2022 in Python by narikkadan
• 63,420 points
35,002 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
34,799 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,585 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,560 points
34,084 views
+2 votes
2 answers

ImportError: numpy.core.multiarray failed to import

try this... run this code one by one.... pip ...READ MORE

Nov 5, 2020 in Python by Anand Vijay Rajsri

reshown Nov 5, 2020 by Sirajul 34,027 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,848 views
0 votes
1 answer

How do I upgrade my pycharm from python 2.7 to python 3?

Install Python 3.7(latest version) from the following ...READ MORE

Aug 5, 2019 in Python by Varsha
33,782 views
0 votes
1 answer

Pytesseract : "TesseractNotFound Error: tesseract is not installed or it's not in your path", how do I fix this?

Based on my recent experience with this ...READ MORE

Feb 16, 2022 in Python by Soham
• 9,700 points
33,369 views
0 votes
1 answer

How do I filter query objects by date range in Django?

Hello @kartik, Use Sample.objects.filter(date__range=["2020-01-01", "2020-01-31"]) Or if you are just ...READ MORE

Jun 26, 2020 in Python by Niroj
• 82,880 points
33,015 views
+1 vote
2 answers

What is the difference between .py and .pyc files in Python?

Hi, @Roshni, You can follow a few steps ...READ MORE

Jun 23, 2020 in Python by Gitika
• 65,910 points
32,751 views
–1 vote
2 answers

In Python, How do I read 2 CSV files, compare column 1 from both, and then write to a new file where the Column 1s match?

Hi @Mike. First, read both the csv ...READ MORE

Jul 24, 2019 in Python by Omkar
• 69,210 points
32,510 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,866 views
0 votes
2 answers

NameError: name 'raw_input' is not defined

Hi, There may a problem with your python ...READ MORE

Jun 25, 2020 in Python by MD
• 95,440 points
31,806 views
0 votes
1 answer

UnicodeDecodeError: "utf-8" codec can"t decode byte 0xeb in position 8: unexpected end of data

To read this dataset use encoding as ...READ MORE

Jul 15, 2019 in Python by Rishi
31,689 views
0 votes
2 answers

Python Error: No python at 'C:\Users\dell\Appdata\Local\Programs\Python\Python37-32\python.exe'

did you solve this problem? i have ...READ MORE

Aug 20, 2020 in Python by anonymous
29,959 views
0 votes
1 answer

mysql.connector.errors.NotSupportedError: Authentication plugin 'caching_sha2_password' is not supported

Hi@akhtar, According to SQL documentation for python library. you ...READ MORE

Jul 15, 2020 in Python by MD
• 95,440 points
29,919 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,915 views
0 votes
1 answer

How do I execute multiple SQL statements at once? - Python

You can use sqlite3 module. Have a ...READ MORE

Jun 20, 2019 in Python by Travis
29,795 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,775 views
0 votes
1 answer

Python Error ""ValueError: could not broadcast input array from shape (4) into shape (1000)""

There are better ways of achieving the ...READ MORE

Jun 14, 2019 in Python by Faiza
29,701 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
29,300 views
0 votes
1 answer

Python TypeError: 'list' object is not callable.

The error says the list is not ...READ MORE

Feb 9, 2019 in Python by Omkar
• 69,210 points
28,760 views
0 votes
1 answer

Create a constant in Python?

No there is not. You cannot declare ...READ MORE

Aug 24, 2018 in Python by Priyaj
• 58,090 points
28,549 views
0 votes
1 answer

ValueError("arrays must all be same length") ValueError: arrays must all be same length

Hi,  You need to specify index for your ...READ MORE

Jun 25, 2020 in Python by MD
• 95,440 points
28,270 views
0 votes
1 answer

how to solve this IndexError: list index out of range in python and streamlit?

Hi,  @Erick, To solve the “index error: list ...READ MORE

Sep 25, 2020 in Python by Roshni
• 10,520 points
27,994 views
0 votes
1 answer

What is the difference between driver.close() and driver.quit()?

They do a similar thing but not ...READ MORE

Apr 6, 2019 in Python by Yash
27,963 views
0 votes
2 answers

How to click button selenium python?

Selenium can automatically click on buttons that ...READ MORE

Oct 14, 2020 in Python by Danish Bhatiya
27,925 views
0 votes
1 answer

What is the difference between pop() and remove()?

Array elements can be removed using pop() ...READ MORE

Jun 20, 2019 in Python by Nisa
• 1,090 points
27,785 views
0 votes
1 answer

Create an empty list in python with certain size

Try this instead: lst = [None] * 10 The ...READ MORE

Aug 2, 2018 in Python by bug_seeker
• 15,520 points
27,769 views
0 votes
1 answer

Pandas df header on 2 row

By default when you import a file, ...READ MORE

Apr 4, 2019 in Python by Yogi
27,764 views
0 votes
1 answer

How to parse `request.body` from POST in Django?

Hello @kartik, In Python 3.0 to Python 3.5.x, json.loads() will ...READ MORE

Aug 5, 2020 in Python by Niroj
• 82,880 points
27,563 views
+2 votes
6 answers

How can I change directory or "cd" in Python?

Context Manager: cd import os class cd:     """Context manager for ...READ MORE

Oct 18, 2018 in Python by Nabarupa
27,489 views
+2 votes
2 answers

ModuleNotFoundError: No module named 'pyttsx3

Hi@akhtar, To avoid this error you have to ...READ MORE

Apr 24, 2020 in Python by MD
• 95,440 points
27,473 views
0 votes
3 answers