Most viewed questions in Python

0 votes
1 answer

How to create blank csv file in pandas?

Try this code: open("User data.csv", 'w') Where User data.csv ...READ MORE

Apr 6, 2019 in Python by Will
4,170 views
0 votes
0 answers

AttributeError: 'numpy.int32' object has no attribute 'map'

can any one suggest solution data['isLarge'] = data.size.map({'small' ...READ MORE

Sep 5, 2020 in Python by Mohammed
• 120 points
4,168 views
+1 vote
1 answer

I want to understand the difference between delete, remove and pop, in Python.

Hi, Lets look at all the methods one ...READ MORE

Jun 7, 2019 in Python by Taj
• 1,080 points
4,161 views
0 votes
1 answer

How to count number of anchor tags got?

I had a similar requirement, this is ...READ MORE

Apr 2, 2019 in Python by Riya
4,159 views
0 votes
1 answer

ModuleNotFoundError: No module named 'cv2'

Check if it's installed properly, It will work ...READ MORE

Oct 12, 2020 in Python by Gitika
• 65,910 points
4,154 views
0 votes
1 answer

How to change the default Django date template format?

Hello @kartik, Within your template, you can use ...READ MORE

Aug 7, 2020 in Python by Niroj
• 82,880 points
4,136 views
0 votes
1 answer

How to debug Django commands in PyCharm?

Hello @kartik, You can debug a custom Django ...READ MORE

Aug 17, 2020 in Python by Niroj
• 82,880 points
4,131 views
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,116 views
0 votes
1 answer

Bypassing Cloudflare Scrapeshield

Scrapeshield basically checks if you are using ...READ MORE

Jun 24, 2019 in Python by SDeb
• 13,300 points
4,107 views
0 votes
1 answer

How can I enable CORS on Django REST Framework?

Hello @kartik, Take the following steps to enable ...READ MORE

Jun 30, 2020 in Python by Niroj
• 82,880 points
4,063 views
0 votes
1 answer

How to check plural & singular form of a word?

You can try with the inflect 0.2.4 ...READ MORE

Jan 3, 2019 in Python by anonymous
4,058 views
0 votes
1 answer

how to fetch user details and send it to his email address using django rest framework

Hello @mahesh, First you have to fetch user ...READ MORE

Aug 18, 2020 in Python by Niroj
• 82,880 points
4,048 views
0 votes
1 answer

AssertionError: <class 'numpy.ndarray'>

Same problem here bro! READ MORE

Dec 8, 2020 in Python by Bijoy
4,036 views
0 votes
1 answer

How to make a single legend for many subplots with matplotlib?

Hello @kartik, There is  nice function get_legend_handles_labels() you can call ...READ MORE

May 7, 2020 in Python by Niroj
• 82,880 points
4,022 views
0 votes
1 answer

TkInter Grid Overlapping Issue

Tkinter is fairly efficient. And for the ...READ MORE

Apr 17, 2018 in Python by anonymous
4,018 views
+1 vote
1 answer

How to save image/file through django shell?

Hii @kartik, You will end up with the ...READ MORE

Jun 29, 2020 in Python by Niroj
• 82,880 points
4,017 views
0 votes
1 answer

What does AF_INET mean?

AF_INET refers to Address from the Internet ...READ MORE

Jul 3, 2019 in Python by Wajiha
• 1,950 points
4,014 views
+1 vote
0 answers

ValueError help with Simple Exponential Smoothing analysis on my data set.

I'm very new, and attempting to teach ...READ MORE

Jul 31, 2019 in Python by Declan

edited Jul 31, 2019 4,011 views
+1 vote
1 answer

How to convert a PIL Image into a numpy array?

Hello @kartik, You just need to convert your ...READ MORE

Jun 22, 2020 in Python by Niroj
• 82,880 points
3,994 views
0 votes
1 answer

if/else in a list comprehension

You can totally do that. It's just ...READ MORE

Dec 23, 2020 in Python by Gitika
• 65,910 points
3,992 views
0 votes
1 answer

'NodeList' object has no attribute 'firstChild'

Use the following piece of code: from xml.dom ...READ MORE

Jul 22, 2019 in Python by Wajiha
• 1,950 points
3,991 views
0 votes
0 answers

Size is (121,512,512). Error is coming as : IndexError: index 152 is out of bounds for axis 0 with size 121.

def nodule_detect(nodules,j,numpyImage, numpyOrigin, numpySpacing): ...READ MORE

Jan 28, 2020 in Python by anonymous
• 150 points
3,970 views
+1 vote
1 answer

How to print a pyramid of asterisks in Python?

This is one of the most frequently ...READ MORE

Aug 1, 2019 in Python by Neel
• 3,020 points
3,955 views
0 votes
1 answer

How to check if any value is NaN in a Pandas DataFrame?

Hello @kartik, If you need to know how ...READ MORE

Jun 15, 2020 in Python by Niroj
• 82,880 points
3,949 views
0 votes
1 answer

How to run Django's test database only in memory?

Hello @kartik, If you set your database engine ...READ MORE

Jun 24, 2020 in Python by Niroj
• 82,880 points
3,937 views
0 votes
1 answer

fatal error: Python.h: No such file or directory

On Ubuntu, I was running Python 3 ...READ MORE

Nov 28, 2020 in Python by Gitika
• 65,910 points
3,935 views
0 votes
1 answer
0 votes
1 answer

Error in Django 2.1.5 Method Not Allowed

UpdateView only allows GET and POST... if ...READ MORE

Nov 12, 2020 in Python by Gitika
• 65,910 points
3,908 views
0 votes
1 answer

Weird Function Using python

input_str = input() input_list = input_str.split(',') a = int(input_list[0]) b ...READ MORE

Jul 28, 2020 in Python by Vin
3,899 views
+1 vote
1 answer

Understanding Python super() with __init__() methods

It's been noted that in Python 3.0+ ...READ MORE

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

Django 1.7: Makemigration: non-nullable field

As the order field is unique, you'll ...READ MORE

May 9, 2019 in Python by SDeb
• 13,300 points
3,889 views
0 votes
1 answer

Error:“Unknown command syncdb” running “python manage.py syncdb”

Hello @kartik, $python manage.py syncdb is deprecated and not ...READ MORE

Aug 5, 2020 in Python by Niroj
• 82,880 points
3,874 views
+1 vote
1 answer

Web Scraping with Python:-> ModuleNotFoundError: no module named 'selenium'

Hello @shamsher, First try to check what version ...READ MORE

Aug 10, 2020 in Python by Niroj
• 82,880 points
3,871 views
0 votes
1 answer

Object of type ObjectId is not JSON serializable, how to send mongo object as json while return?

Hi, @There, Make sure that your MongoDB instance ...READ MORE

Oct 13, 2020 in Python by Gitika
• 65,910 points
3,861 views
0 votes
2 answers

How to change the font size on a matplotlib plot?

Functions dealing with text like label, title, etc. accept ...READ MORE

Jan 4, 2021 in Python by Carlos
3,857 views
0 votes
1 answer

Replace values in data frame with valued of another dataframe.

Hi @Puneeth, you use something like this: f ...READ MORE

May 30, 2019 in Python by Ashish
3,849 views
0 votes
2 answers

Equivalent of a?b:c in Python

result = "F" if(isfemale_bit) else "M" print(result) Try this ...READ MORE

Dec 15, 2019 in Python by Manel
3,849 views
+1 vote
1 answer

How do you express binary literals in Python?

Starting with Python 2.6 you can express ...READ MORE

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

edited Dec 21, 2023 by Khan Sarfaraz 3,825 views
0 votes
1 answer

How to remove all of the data in a table using Django?

Hello @kartik, Inside a manager: def delete_everything(self): ...READ MORE

Aug 12, 2020 in Python by Niroj
• 82,880 points
3,819 views
0 votes
1 answer

how can i extact all the links from a website using python and save it in a csv file ?

Hi, @Shubham, Web scraping is the technique to ...READ MORE

Jun 16, 2020 in Python by Gitika
• 65,910 points
3,818 views
0 votes
1 answer

Make turtle face a particular direction in python

You can use the the setheading command turtle.setheading(<degrees/radians>) In ...READ MORE

Jul 8, 2019 in Python by Jinu
3,817 views
0 votes
1 answer

How to filter my model on the basis of text length in django?

Hello @kartik, For Django >= 1.8 you can ...READ MORE

Aug 13, 2020 in Python by Niroj
• 82,880 points
3,802 views
0 votes
1 answer

ModuleNotFoundError: No module named 'pymc3'

Hi@akhtar, You need to install this module in ...READ MORE

Jun 30, 2020 in Python by MD
• 95,440 points
3,775 views
0 votes
1 answer

What will be the output of below code and why? x=[1,2,3,4,5] print(x.insert(2,3))

If you write x.insert(2,3) and then print x ...READ MORE

Oct 14, 2020 in Python by Gitika
• 65,910 points
3,765 views
0 votes
1 answer

Increment with ++ in Python

Python doesn't support ++, so we use: number ...READ MORE

Nov 8, 2018 in Python by SDeb
• 13,300 points
3,761 views
0 votes
1 answer

What is the difference between Python and IPython?

There are few differences between Python and ...READ MORE

Jul 26, 2018 in Python by Priyaj
• 58,090 points
3,757 views
0 votes
1 answer

Restart python script automatically even when it crashes in Linux

Maybe this would be more robust? 1) save ...READ MORE

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

How to make the user in a model default to the current user?

Hello @kartik, You have to override get_changeform_initial_data method in your ...READ MORE

Jun 12, 2020 in Python by Niroj
• 82,880 points
3,721 views
0 votes
1 answer

How to invoke a function on an object dynamically by name?

Use "getattr":  obj = MyClass() try: ...READ MORE

Dec 3, 2020 in Python by Gitika
• 65,910 points
3,705 views
+1 vote
0 answers

ValueError: could not broadcast input array from shape (2) into shape (5) [closed]

I was implementing gillespie algorithm and when ...READ MORE

Dec 23, 2019 in Python by anonymous
• 130 points

reshown Jan 13, 2020 by Kalgi 3,704 views