Most viewed questions in Python

0 votes
1 answer

Error:Manager isn't accessible via model instances

Hello @kartik, The error caused when you try ...READ MORE

Aug 17, 2020 in Python by Niroj
• 82,880 points
6,070 views
0 votes
1 answer

Error:Pip install: can't open file pip, or Parent module '' not loaded

Hello @kartik, Assuming you have pip installed and ...READ MORE

Jul 3, 2020 in Python by Niroj
• 82,880 points
6,024 views
0 votes
1 answer

How to parse the Excel format XML using Python?

Hi, @Hikmat, Regarding your query, you have to ...READ MORE

Sep 24, 2020 in Python by Roshni
• 10,520 points
6,013 views
0 votes
1 answer

Difference between Python float and numpy float32

Python's standard float type is a C ...READ MORE

Mar 4, 2019 in Python by SDeb
• 13,300 points
6,010 views
+1 vote
0 answers

ValueError: operands could not be broadcast together with shapes (3,) (1000,)

This is the part of my code, why ...READ MORE

May 17, 2020 in Python by anonymous
• 220 points

edited May 18, 2020 by Gitika 6,004 views
0 votes
1 answer

How to do math in a Django template?

Hello @kartik, You can use the add filter: {{ object.article.rating_score|add:"-100" }} Thank ...READ MORE

Jun 23, 2020 in Python by Niroj
• 82,880 points
6,002 views
0 votes
0 answers

how to get mongoengine object id in flask program

i am using mongoengine to integrate with ...READ MORE

Oct 5, 2018 in Python by eatcodesleeprepeat
• 4,710 points
5,998 views
0 votes
1 answer

Django form validation: making “required” conditional?

This is done with the clean method on the ...READ MORE

Aug 30, 2018 in Python by Priyaj
• 58,090 points
5,997 views
0 votes
1 answer

Sort list by frequency in python

You can try the following for a ...READ MORE

May 13, 2019 in Python by SDeb
• 13,300 points
5,969 views
0 votes
1 answer

Understanding repr( ) function in Python

>>> x = 'foo' >>> x 'foo' So the name x is ...READ MORE

Sep 17, 2018 in Python by Priyaj
• 58,090 points
5,925 views
0 votes
1 answer

What does the penup() do in Python(turtle module)

penup() basically makes sure that the moving ...READ MORE

Jun 21, 2019 in Python by Iris
5,920 views
0 votes
1 answer

How to suppress console output in Python?

You can try the following block of ...READ MORE

Jun 7, 2019 in Python by SDeb
• 13,300 points
5,918 views
0 votes
1 answer

How to convert list into 2 tuple pair list?

This should work: L = [1, 2, 3, ...READ MORE

Nov 4, 2020 in Python by Gitika
• 65,910 points
5,911 views
0 votes
1 answer

How can I have only positive decimal numbers in Django using Python?

Hi, are you aware of something called ...READ MORE

Jan 30, 2019 in Python by Nymeria
• 3,560 points
5,895 views
0 votes
1 answer

Error:'QuerySet' object has no attribute 'remove'

Hello @kartik, You could do this: import itertools ids = ...READ MORE

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

How can I import tensorflow libraries in my Python code?

You are doing it wrong as tf is not ...READ MORE

Dec 31, 2018 in Python by charlie_brown
• 7,720 points
5,883 views
0 votes
1 answer

React native for frontend and python is for backend app development it is possible??

Hello @Rithika , Yes, it is possible. For example, you ...READ MORE

Oct 30, 2020 in Python by Niroj
• 82,880 points
5,869 views
0 votes
1 answer

How to add annotate data in django-rest-framework queryset responses?

Hello @kartik, The queryset returned from get_queryset provides ...READ MORE

Jun 25, 2020 in Python by Niroj
• 82,880 points
5,850 views
0 votes
1 answer

Read Nested Json as DataFrame

Here is the code for it. da=[ {"age":34, "id":1, "name":"Tony", "salary":1400, "dept_no":[10,20], "Cntct":{"Phone":[1234567890,9876543210], "state":"NY", ...READ MORE

Jul 25, 2019 in Python by Jimmy
5,849 views
0 votes
1 answer

How to query as GROUP BY in django?

Hii, Django does not support free group by ...READ MORE

Apr 23, 2020 in Python by Niroj
• 82,880 points
5,846 views
0 votes
1 answer

I am not able to install pywin32 into my Macos ..I tried all the ways and I could not fix the error...can you please help me

Hello @Harikrishna, For your query you can refer ...READ MORE

Nov 23, 2020 in Python by Niroj
• 82,880 points
5,827 views
0 votes
1 answer

Python error "AttributeError: 'str' object has no attribute 'casefold'"

Check your python version. Casefold is possible ...READ MORE

Jul 4, 2019 in Python by Yesha
5,815 views
0 votes
1 answer
0 votes
1 answer

ModuleNotFoundError: No module named 'twilio'

Hi@akhtar, It seems you don't have a Twilio ...READ MORE

Jun 25, 2020 in Python by MD
• 95,440 points
5,794 views
0 votes
0 answers

Python error "ERROR: Can not perform a '--user' install. User site-packages are not visible in this virtualenv."

I tried upgrading pip using the following ...READ MORE

Oct 3, 2019 in Python by Hannah
• 18,570 points
5,784 views
0 votes
1 answer

ImportError: No module named django_extensions

Hello @kartik, You can solve this error by ...READ MORE

Jun 25, 2020 in Python by Niroj
• 82,880 points
5,783 views
0 votes
1 answer

How to use multiprocessing queue in Python?

This is a simple example of a ...READ MORE

Oct 25, 2018 in Python by SDeb
• 13,300 points
5,779 views
0 votes
1 answer

Pass --no-deps in PIP requirements.txt

There is no such option yet for ...READ MORE

Jun 25, 2019 in Python by SDeb
• 13,300 points
5,762 views
+1 vote
2 answers

How to automate image upload from my computer to site using python-selenium?

Hey, this code worked for me: image_path=os.path.abspath('.\\folder1\\subfolder2\file1.jpg') driver.find_element_by_id("Id of ...READ MORE

Aug 19, 2019 in Python by Rishi
5,720 views
+1 vote
1 answer

Python code to determine its day or night

Try something like this: sample data: (timezone= utc/zulutime) ...READ MORE

Jun 21, 2019 in Python by Imran
5,708 views
+1 vote
2 answers

Error:Django gives Bad Request (400) when DEBUG = False

Tried this and it resolved all my ...READ MORE

Sep 25, 2020 in Python by Agaba
5,685 views
0 votes
1 answer

converting timedelta to float

Use the following piece of code: x1=datetime.timedelta(days=3000, seconds=0, ...READ MORE

Aug 8, 2019 in Python by Wajiha
• 1,950 points
5,650 views
0 votes
1 answer

Pandas print the first few rows of dataframe

Pandas allows you to slice the dataframe ...READ MORE

May 9, 2019 in Python by Shri
5,611 views
0 votes
0 answers

AttributeError: 'Index' object has no attribute 'get_values'

parameters = pd.read_csv(params_filename, sep="\t") free_parameters = parameters.columns.get_values().to_list() free_parameters = ...READ MORE

Sep 7, 2020 in Python by Swastik
• 120 points
5,604 views
0 votes
2 answers

How to upgrade all Python packages with pip?

Open the command prompt and check the ...READ MORE

Jun 7, 2020 in Python by sahil
• 580 points
5,601 views
0 votes
1 answer

How Django rest framework override page_size in ViewSet?

Hello @kartik, Fixed this by creating custom pagination ...READ MORE

Jul 2, 2020 in Python by Niroj
• 82,880 points
5,577 views
0 votes
1 answer

i am normalizing the data set iris in python and get the error ::TypeError: 'numpy.float64' object is not callable

TRY THIS   #Nomalisation for i in names:     print(i)   ...READ MORE

Aug 20, 2019 in Python by Noel Deepak Palle
5,537 views
0 votes
1 answer

How to create a train and test sample from one dataframe using pandas?

Hi, The below written code can help you ...READ MORE

Jul 4, 2019 in Python by Taj
• 1,080 points
5,521 views
0 votes
1 answer

Getting first row from sqlalchemy

Use  query.one() to get one result. In ...READ MORE

Feb 21, 2019 in Python by SDeb
• 13,300 points
5,513 views
0 votes
1 answer

How to order_by a JSON from serializers.py file in django rest framework?

Hello @kartik, There's an easy way, just override ...READ MORE

Jul 2, 2020 in Python by Niroj
• 82,880 points
5,501 views
0 votes
1 answer

IndentationError: expected an indented block

Hello @ nishit, Indentation means the space from margin to ...READ MORE

Aug 10, 2020 in Python by Niroj
• 82,880 points
5,480 views
+1 vote
2 answers

Does 'finally' always execute in Python?

The "finally" executes almost everytime. But there ...READ MORE

Aug 31, 2018 in Python by Omkar
• 69,230 points
5,477 views
0 votes
1 answer

urllib.error.URLError: <urlopen error [Errno -2] Name or service not known>

Hi@akhtar, You need to use the read function in ...READ MORE

Jul 15, 2020 in Python by MD
• 95,440 points
5,471 views
0 votes
1 answer

Why does DEBUG=False setting make my django Static Files Access fail?

Hello @kartik, If you still need to server ...READ MORE

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

Error while printing hello world in python.

You must be trying this command in ...READ MORE

Mar 31, 2018 in Python by GandalfDwhite
• 1,320 points
5,448 views
0 votes
1 answer

a basic question about “while true”

while True means loop forever. The while ...READ MORE

Jun 4, 2018 in Python by aryya
• 7,450 points
5,441 views
0 votes
1 answer

How to show Image from Imagefield Django Admin ?

Hello @kartik, In your model class add a ...READ MORE

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

How to find path of Python interpreter?

In Python, the sys module has System-specific ...READ MORE

Jul 26, 2019 in Python by Arvind
• 3,040 points
5,424 views
0 votes
1 answer

Python: is thread still running

The key is to start the thread ...READ MORE

Aug 5, 2019 in Python by SDeb
• 13,300 points
5,415 views