Most viewed questions in Python

0 votes
3 answers
0 votes
1 answer

How to convert multiple columns to string in pandas dataframe?

Hi, To convert multiple columns to string, include a list of ...READ MORE

Jul 19, 2019 in Python by Taj
• 1,080 points
28,453 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,510 points
28,355 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
28,278 views
0 votes
1 answer

Django object is not JSON serializable

Hello @kartik, simplejson and json don't work with django objects well. Django's ...READ MORE

Aug 7, 2020 in Python by Niroj
• 82,840 points
28,267 views
0 votes
1 answer

'NoneType' object has no attribute 'text

Hello @Muhammad Umer, As per the Beautiful Soup Documentation: AttributeError: ...READ MORE

Dec 7, 2020 in Python by Niroj
• 82,840 points
28,253 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 8, 2019 in Python by anonymous
28,133 views
0 votes
1 answer

ValueError: malformed string when using ast.literal_eval

Hello Kartik, An updated version of the answer ...READ MORE

May 27, 2020 in Python by Niroj
• 82,840 points
27,101 views
0 votes
1 answer

%matplotlib inline SyntaxError: invalid syntax

If you're using Jupyter notebook, just mention this ...READ MORE

Aug 1, 2019 in Python by Merlin

edited Jun 25, 2020 by MD 26,570 views
0 votes
2 answers

UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte

Hey,  @Himanshu. It's still most likely gzipped data. ...READ MORE

Jul 27, 2020 in Python by Gitika
• 65,770 points
25,791 views
0 votes
1 answer

Python: ImportError: No module named Crypto.Cipher

Seems like the pycrypto package is not ...READ MORE

Jul 31, 2019 in Python by Hari
25,561 views
0 votes
1 answer

I am trying to install PIL module But I end up with an error :

Hi@Nishant, You can use PILLOW instead of PIL. $ ...READ MORE

Apr 6, 2020 in Python by MD
• 95,460 points
25,205 views
0 votes
1 answer

Difference between end and sep

end and sep are optional parameters of ...READ MORE

Jul 30, 2019 in Python by Wajiha
• 1,960 points
25,158 views
0 votes
11 answers

“pip install unroll”: “python setup.py egg_info” failed with error code 1

rm -rf node_modules READ MORE

Jun 27, 2019 in Python by anonymous
25,001 views
+1 vote
2 answers

ModuleNotFoundError: No module named 'selenium'

i fix the problem after installing go ...READ MORE

Nov 18, 2020 in Python by ahmed
24,949 views
0 votes
2 answers

Python error "ImportError: No module named 'tkinter'"

sudo apt-get install python3-tk Then, >> import tkinter # ...READ MORE

Nov 9, 2019 in Python by Icetutor
• 160 points
24,928 views
0 votes
1 answer

ImportError: No module named matplotlib.pyplot

Hi@akhtar, It seems you don't have matplotlib library ...READ MORE

Jun 22, 2020 in Python by MD
• 95,460 points
24,923 views
0 votes
1 answer

How to set Colorbar Range in matplotlib using Python

You could scale your data to the ...READ MORE

Nov 22, 2018 in Python by Nymeria
• 3,560 points
24,679 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
• 58,020 points
24,629 views
0 votes
1 answer

How to terminate a python script?

This can be done by importing the ...READ MORE

Aug 9, 2019 in Python by Arvind
• 3,050 points
24,349 views
0 votes
1 answer

Input() error - NameError: name '…' is not defined

Hello @kartik, You should use raw_input if you are ...READ MORE

May 5, 2020 in Python by Niroj
• 82,840 points
24,098 views
0 votes
2 answers

How can I write a program to add two numbers using functions in python?

there is sum() function as a built ...READ MORE

Oct 25, 2020 in Python by anonymous
24,096 views
0 votes
2 answers

What's the difference between %s and %d in Python string formatting?

The reason is that they are using ...READ MORE

Feb 8, 2022 in Python by Rahul
• 9,680 points
24,053 views
0 votes
1 answer

How to import a folder in Jupyter Notebook?

Hi@akhtar, There is no simple way to import ...READ MORE

Aug 17, 2020 in Python by MD
• 95,460 points
23,803 views
0 votes
0 answers

Python shopping cart add to cart, get total get num items

I want to loop through the list ...READ MORE

Apr 25, 2022 in Python by Kichu
• 19,040 points
23,787 views
0 votes
1 answer

ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

Hello @kartik, Since different users might have different ...READ MORE

Jun 15, 2020 in Python by Niroj
• 82,840 points
23,702 views
0 votes
2 answers

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

x="malayalam" y="" for i in x: ...READ MORE

Nov 3, 2020 in Python by Thangaraj
23,647 views
0 votes
1 answer

Is it possible in Python requests to print entire HTTP request?

A better idea is to use the ...READ MORE

Nov 26, 2018 in Python by Nymeria
• 3,560 points
23,518 views
+1 vote
1 answer

How to check if a string is null in python

I want to check if any NULL ...READ MORE

Mar 9, 2022 in Python by satish

edited Mar 5 23,491 views
+1 vote
2 answers

Python error "ZeroDivisionError: float division by zero"

The error is thrown in this line matchPercentage ...READ MORE

May 21, 2020 in Python by Prabhakar
23,342 views
0 votes
1 answer

python JSON only get keys in first level

You just need a simple .keys() >>> dct ...READ MORE

Jan 22, 2019 in Python by SDeb
• 13,300 points
23,237 views
0 votes
1 answer

Python error "TypeError: string indices must be integers, not str"

Hey @Dipti email_s.append(email_1["email_address"]) This is the list on ...READ MORE

Jul 5, 2019 in Python by Jinu
23,108 views
0 votes
1 answer

How to print the index of a Pandas Dataframe?

You can do this using the code ...READ MORE

May 13, 2019 in Python by Usha
22,893 views
0 votes
1 answer

Python: “TypeError: Object type <class 'str'> cannot be passed to C code”

You have to pass byte string as ...READ MORE

Aug 20, 2019 in Python by Jishan
22,770 views
0 votes
1 answer
+1 vote
2 answers

How to display column names of Pandas Dataframe?

print(list(your_df)) READ MORE

Jan 18, 2020 in Python by anonymous
22,484 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
22,254 views
0 votes
1 answer

How to Pivot pandas for removing of some headers and renaming of some indexes?

Solution is add parameter values to pivot, then add reset_index for column ...READ MORE

Sep 27, 2018 in Python by Priyaj
• 58,020 points
22,184 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
22,063 views
0 votes
1 answer

TypeError: 'AxesSubplot' object does not support indexing

Hello , If you plot multiple subplots, the plt.subplots() returns ...READ MORE

May 7, 2020 in Python by Niroj
• 82,840 points
21,911 views
0 votes
1 answer

AttributeError: module 'numpy' has no attribute '__version__'

Hi@akhtar, To avoid this error you can use ...READ MORE

Apr 20, 2020 in Python by MD
• 95,460 points
21,830 views
0 votes
1 answer

How to delete conda env permanently?

First you check conda enviorment from following ...READ MORE

Jan 22, 2021 in Python by Muhammad Tariq

edited Mar 5 21,646 views
0 votes
2 answers

Tkinter “module not callable” error.

This error statement TypeError: 'module' object is ...READ MORE

Jun 27, 2019 in Python by rahul
• 360 points
21,642 views
0 votes
1 answer
0 votes
1 answer

How to get two tags in findall using BeautifulSoup?

You can mention both the tags in ...READ MORE

Apr 2, 2019 in Python by Giri
21,275 views
0 votes
2 answers

Removing Title bar in Tkinter program

you can remove the title bar by ...READ MORE

Mar 19, 2019 in Python by anonymous
21,157 views
0 votes
1 answer

Exception in Tkinter callback Traceback (most recent call last):

Hello, @R, As per the Beautiful Soup Documentation: AttributeError: 'NoneType' ...READ MORE

Dec 21, 2020 in Python by Gitika
• 65,770 points
21,139 views
0 votes
1 answer

ValueError: could not broadcast input array from shape (360,270,3) into shape (360,280,3)

Hi@akhtar, In the above error it shows could not ...READ MORE

Apr 9, 2020 in Python by MD
• 95,460 points
20,830 views
0 votes
1 answer

Python Requests module - Import Error: No module named requests

Run with Python 3 from the command ...READ MORE

Sep 11, 2020 in Python by Malik Brahimi
20,804 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
• 58,020 points
20,712 views