Trending questions in Python

0 votes
1 answer

How to update user password in Django Rest Framework?

Hello @kartik, Using a modelserializer might be an ...READ MORE

Jul 1, 2020 in Python by Niroj
• 82,840 points
9,543 views
0 votes
1 answer

How to store a dictionary on a Django Model?

Hello @kartik, If you don't need to query ...READ MORE

Jun 29, 2020 in Python by Niroj
• 82,840 points
9,556 views
0 votes
1 answer

ImportError: Import by filename is not supported

Instead of doing a import like __import__ you can ...READ MORE

Nov 26, 2020 in Python by Gitika
• 65,770 points
3,068 views
0 votes
1 answer

What is the equivalent of “none” in django templates?

Hello @kartik, None, False and True all are available ...READ MORE

Jul 3, 2020 in Python by Niroj
• 82,840 points
9,361 views
0 votes
1 answer

Is it possible to break a long line to multiple lines in Python?

Example of implicit line continuation: a = some_function( ...READ MORE

Jan 4, 2021 in Python by Gitika
• 65,770 points
1,350 views
0 votes
0 answers

can't compare offset-naive and offset-aware datetimes

While I'm Trying to Compare Two dates ...READ MORE

Dec 12, 2020 in Python by Mohamed
• 170 points
2,332 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
1,207 views
0 votes
1 answer

AttributeError: 'Group' object has no attribute 'user'

You can go through this: from django.contrib.auth.models import ...READ MORE

Nov 12, 2020 in Python by Gitika
• 65,770 points
3,575 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
1,197 views
0 votes
1 answer

How to create a GUID/UUID in Python?

Hello @kartiK, If you need to pass UUID ...READ MORE

Dec 8, 2020 in Python by Niroj
• 82,840 points
2,446 views
+1 vote
1 answer

How do I find out the sum of digits of a number in Python?

Hi, good question. If you are considering ...READ MORE

Feb 7, 2019 in Python by Nymeria
• 3,560 points
8,358 views
0 votes
1 answer

Error: Failed building wheel for MySql-Python

Hello @kartik, You need to install the following ...READ MORE

Jul 3, 2020 in Python by Niroj
• 82,840 points
9,292 views
0 votes
1 answer

Call a function from another file?

There isn't any need to add file.py while importing. ...READ MORE

Jan 5, 2021 in Python by Gitika
• 65,770 points
1,230 views
0 votes
1 answer

How to match all occurrences of a regex?

Using scan should do the trick: string.scan(/regex/) READ MORE

Nov 25, 2020 in Python by Gitika
• 65,770 points
3,010 views
0 votes
1 answer

How to get value from form field in django framework?

Hello @kartik, Using a form in a view can ...READ MORE

Jun 30, 2020 in Python by Niroj
• 82,840 points
9,368 views
0 votes
0 answers

how to fix this error in python ;ModuleNotFoundError: No module named 'download'?

hello i am a beginner in machine ...READ MORE

Feb 2, 2021 in Python by anonymous

edited Mar 4 19 views
0 votes
1 answer

ERROR: Could not build wheels for line-profiler which use PEP 517 and cannot be installed directly.

Hi@akhtar, If you are trying to install with pip ...READ MORE

Nov 5, 2020 in Python by MD
• 95,460 points
3,774 views
0 votes
1 answer

How to find the occurrences of any word with more than two vowels in a file using regex?

for word in read: <--- iterating ...READ MORE

Nov 25, 2020 in Python by Gitika
• 65,770 points
2,915 views
0 votes
1 answer

How to Remove specific characters from a string in Python?

Strings in Python are immutable (can't be changed). Because ...READ MORE

Jan 5, 2021 in Python by Gitika
• 65,770 points
1,098 views
0 votes
0 answers

How to write df to excel without attribute error, and how to add 2 header columns (1 header, 1 units)

Hi, I am very new to Python ...READ MORE

Jun 3, 2020 in Python by Edureka
• 120 points

edited Jun 5, 2020 by Gitika 10,467 views
0 votes
1 answer

How to get the position of a character in Python?

There are two string methods for this, find() and index(). ...READ MORE

Jan 5, 2021 in Python by Gitika
• 65,770 points
1,090 views
0 votes
1 answer

What does request.user refer to in Django?

Hello @kartik, request.user is User model object. You cannot access ...READ MORE

Jun 23, 2020 in Python by Niroj
• 82,840 points
9,531 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
1,299 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,770 points
4,696 views
0 votes
1 answer

ModuleNotFoundError: No module named 'bs4'

Hi@akhtar, You need to install the bs4 package ...READ MORE

Jun 26, 2020 in Python by MD
• 95,460 points
9,358 views
0 votes
1 answer

Adding new column to existing DataFrame in Python pandas

Use the original df1 indexes to create ...READ MORE

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

ERROR: PyAudio-0.2.11-cp39-cp39-win_amd64.whl is not a supported wheel on this platform.

Hi, @Henll, You should download the version that ...READ MORE

Oct 22, 2020 in Python by Gitika
• 65,770 points
4,220 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
6,221 views
0 votes
1 answer

ModuleNotFoundError: No module named 'torch'

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

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

How to import a module given the full path?

For Python 3.5+ use: import importlib.util spec = importlib.util.spec_from_file_location("module.name", ...READ MORE

Nov 25, 2020 in Python by Gitika
• 65,770 points
2,751 views
0 votes
1 answer

Error: IndexError: list index out of range and python

IndexError The IndexError is raised when you attempt to retrieve ...READ MORE

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

How to insert a date into MySQL using Python?

Hi@akhtar, You can use the DateTime module to insert a date into ...READ MORE

Jul 15, 2020 in Python by MD
• 95,460 points
8,445 views
0 votes
1 answer

Error:Expected view to be called with a URL keyword argument named “pk”

Hello @kartik, View functions are called with the ...READ MORE

Jul 2, 2020 in Python by Niroj
• 82,840 points
9,038 views
0 votes
0 answers

Why do I get double spaces if the user has no middle name?

I'm trying to learn Python and this ...READ MORE

Jan 27, 2021 in Python by Benn

edited Mar 4 25 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,682 views
0 votes
0 answers

How do you check if the current user is the same as a foreign key in a model?

I have a model called Tribe which ...READ MORE

Jan 26, 2021 in Python by Andrija

edited Mar 4 23 views
0 votes
1 answer

ImportError: cannot import name 'render_to_response' from 'django.shortcuts'

Hello @kartik, The render_to_response shortcut was deprecated in Django 2.0, and ...READ MORE

Jul 2, 2020 in Python by Niroj
• 82,840 points
8,952 views
0 votes
0 answers

What is this python script doing??

READ MORE

Jan 26, 2021 in Python by patrick

edited Mar 4 23 views
0 votes
0 answers

what is this doing?

READ MORE

Jan 26, 2021 in Python by patrick

edited Mar 4 22 views
0 votes
2 answers

This kind of error throwing AttributeError: __enter__

I had recently found its solution and ...READ MORE

Jul 31, 2020 in Python by lokesh
8,200 views
0 votes
1 answer

Install a Python package into a different directory using pip?

Use: pip install --install-option="--prefix=$PREFIX_PATH" package_name You might also want ...READ MORE

Dec 3, 2020 in Python by Gitika
• 65,770 points
2,242 views
0 votes
1 answer

Error: Unhandled exception in thread started by Error in sys.excepthook:

I think the general idea of the ...READ MORE

Nov 2, 2020 in Python by Gitika
• 65,770 points
3,584 views
0 votes
1 answer

How to print colored text in Python?

This somewhat depends on what platform you ...READ MORE

Dec 17, 2020 in Python by Gitika
• 65,770 points
1,606 views
0 votes
0 answers

Weight calculation for Fico score

how could i calculate weight for fico ...READ MORE

Jan 23, 2021 in Python by Noman
• 220 points

edited Mar 4 23 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,770 points
4,362 views
0 votes
2 answers

How to Import a module from a relative path?

If i understand your question correct then ...READ MORE

Dec 14, 2020 in Python by Tanja84DK

edited Dec 15, 2020 1,791 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,622 views
0 votes
1 answer

How can I disable logging while running unit tests in Python Django?

Hello @kartik, Since you are in Django, you ...READ MORE

Jun 23, 2020 in Python by Niroj
• 82,840 points
9,158 views
0 votes
1 answer

Remove final character from string

Simple: st = "abcdefghij" st = st[:-1] There is ...READ MORE

Jan 5, 2021 in Python by Gitika
• 65,770 points
685 views