Trending questions in Python

0 votes
1 answer

How can I return HTTP status code 204 from a Django view?

Hello, Try this: return HttpResponse(status=204) Hope it works!! ...READ MORE

Aug 17, 2020 in Python by Niroj
• 82,840 points
8,641 views
0 votes
1 answer

how do i print only the last two letters in a string using regular expression in python?

S1="string1" S1[-2::] Output: g1 READ MORE

Jan 5, 2023 in Python by anonymous

edited Mar 5 1,071 views
0 votes
0 answers

How to pass variable in mysql query. Trying to fetch latitude and longitude.

long='73.9876' lati='18.6543' query="SELECT user_id ,SQRT(POW(69.1 * (latitude - lati), ...READ MORE

Mar 3, 2021 in Python by rehan
• 160 points

edited Mar 4 49 views
0 votes
0 answers

int() argument must be a string, a bytes-like object or a number, not 'NoneType'

Hello,  I am trying to convert an object ...READ MORE

Mar 3, 2021 in Python by vijaybhargav

edited Mar 4 29 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,094 views
0 votes
1 answer

How to save a Pandas Dataframe to a pickle file?

Hi@akhtar, Python pickle module is used for serializing ...READ MORE

Oct 18, 2020 in Python by MD
• 95,460 points
5,851 views
0 votes
1 answer

How to check if a float value(decimal number) is between range(0 to 10) in python

Hello,  A function that returns True for an integer number (int or ...READ MORE

Sep 14, 2020 in Python by Niroj
• 82,840 points
7,314 views
0 votes
1 answer

ImportError: No module named sklearn.cross_validation

Regarding your query, it must relate to ...READ MORE

Dec 16, 2020 in Python by Nikita
3,225 views
0 votes
1 answer

Limiting floats to two decimal points?

You are running into the old problem with floating-point ...READ MORE

Dec 2, 2020 in Python by Gitika
• 65,770 points
3,776 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
35,854 views
0 votes
1 answer

How to get the latest file in a folder using python?

Hello @kartik,  would suggest using glob.iglob() instead of the glob.glob(), as ...READ MORE

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

How to execute a Python script from the Django shell?

Hello @kartik, The << part is wrong, use < instead: $ ./manage.py shell ...READ MORE

Jun 22, 2020 in Python by Niroj
• 82,840 points
10,750 views
0 votes
1 answer

ImportError: cannot import name user

Hello @kartik, You missed the models - and ...READ MORE

Aug 17, 2020 in Python by Niroj
• 82,840 points
8,331 views
–1 vote
1 answer

How to get the current URL within a Django template?

Hello @kartik, You can fetch the URL in ...READ MORE

Aug 6, 2020 in Python by Niroj
• 82,840 points
8,811 views
0 votes
0 answers

How to parse the Excel format XML using Python?

I have Excel sheet saved as XML ...READ MORE

Sep 24, 2020 in Python by Hikmat
• 120 points
6,693 views
0 votes
0 answers

Dickey-Fuller test in Python

Dear all, I'm trying to reproduce one of ...READ MORE

Feb 5, 2021 in Python by Marcelo
• 120 points
886 views
0 votes
0 answers

How to use create function instead of perform_create in ListCreateApiView in django rest framework

I am trying to create a booking ...READ MORE

Nov 30, 2020 in Python by anonymous
• 120 points
3,723 views
0 votes
1 answer

How can “list_display” in a Django ModelAdmin display attributes of ForeignKey fields?

Hello @kartik, As another option, you can do ...READ MORE

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

How to combine two columns of text in pandas dataframe?

If both columns are strings, you can ...READ MORE

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

how to solve the error : "ImportError: No module named Tkinter" in python.

Hi@Umama, If you are using Linux system, then ...READ MORE

Apr 27, 2020 in Python by MD
• 95,460 points
13,858 views
0 votes
0 answers

how to fix the ERROR: Could not find a version that satisfies the requirement engine

when I install engine or anyother module ...READ MORE

Jan 3, 2021 in Python by Muhammad Ali
• 120 points
2,164 views
0 votes
1 answer

How do I find the a referring sites URL in node?

Hii, In express 4.x: req.get('Referrer') This will also check both spellings of ...READ MORE

Nov 27, 2020 in Python by Niroj
• 82,840 points
3,704 views
0 votes
1 answer

How do I add a link from the Django admin page of one object to the admin page of a related object?

Hello @kartik, Set show_change_link to True (False by default) in your inline ...READ MORE

Jun 12, 2020 in Python by Niroj
• 82,840 points
10,955 views
0 votes
1 answer

How to prompt for user input and read command-line arguments?

To read user input you can try the cmd module for ...READ MORE

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

How to ignore Headers in S3 bucket CSV file using python?

Hi@durgaraju, You can fetch only the body part. ...READ MORE

Dec 29, 2020 in Python by MD
• 95,460 points
2,310 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,222 views
0 votes
1 answer

Can’t import TensorFlow. Could not find a version that satisfies the requirement TensorFlow

Basically, a solution would be to install ...READ MORE

Oct 15, 2020 in Python by anonymous
• 65,770 points
5,455 views
0 votes
1 answer

Error:'pip' is not recognized as an internal or external command

Hello @kartik, Try this: Type 'start %appdata%' in cmd. After ...READ MORE

Aug 3, 2020 in Python by Niroj
• 82,840 points
8,604 views
0 votes
1 answer

How to find current directory and file's directory?

To get the full path to the ...READ MORE

Dec 17, 2020 in Python by Gitika
• 65,770 points
2,680 views
+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,454 views
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,770 points
4,160 views
0 votes
1 answer

How to update date automatically after a value change in django?

Hello @kartik, Only change your pub_date if published has ...READ MORE

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

Error:AttributeError: 'NoneType' object has no attribute 'extend'

Hello @kartik, You can use itertools.chain(): import itertools list2d = [[1,2,3], ...READ MORE

Nov 18, 2020 in Python by Niroj
• 82,840 points
3,886 views
0 votes
1 answer

Error: current transaction is aborted, commands ignored until end of transaction block?

Hii kartik, To get rid of the error, roll ...READ MORE

Apr 23, 2020 in Python by Niroj
• 82,840 points
12,907 views
0 votes
1 answer

SELENIUM ERROR !!HELP!!

Hi, @There, A possibility is that the element ...READ MORE

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

Error: No module named psycopg2.extensions

Hello @kartik, The first thing to do is ...READ MORE

Aug 17, 2020 in Python by Niroj
• 82,840 points
7,860 views
0 votes
0 answers

ValueError: not enough values to unpack (expected 2, got 0)

I want to load the NSL_KDD data ...READ MORE

May 9, 2020 in Python by arezoo
• 220 points

edited May 13, 2020 by Gitika 12,166 views
0 votes
0 answers

counting the number of occurrences in string

A factory makes products using parts that ...READ MORE

Feb 14, 2021 in Python by viknesann

edited Mar 4 25 views
0 votes
0 answers

a error while executing this Decision tree algorithm code NameError: name 'rows' is not defined

training_data = [     ["Green",3, 'Mango'],     ['Yellow',3,'Mango'],     ['Red',1, 'Grape'],     ['Red',1, 'Grape'],     ['Yellow',3,'Lemon'] ] header = ...READ MORE

Feb 13, 2021 in Python by Piyush

edited Mar 4 31 views
+1 vote
1 answer

How to validate a field on update in DRF?

Hello @kartik, You can definitely do this using ...READ MORE

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

ValueError: must have exactly one of create/read/write/append mode

You can open a file for simultaneous ...READ MORE

Nov 15, 2020 in Python by Gitika
• 65,770 points
3,852 views
0 votes
0 answers

many websites show output code is accessed without print() how can i do that

list_x =[1,2,34] list_x READ MORE

Feb 13, 2021 in Python by mahirz

edited Mar 4 23 views
0 votes
1 answer

Import Error: No module named numpy?

Hello, I had numpy installed on the same ...READ MORE

Apr 14, 2020 in Python by Niroj
• 82,840 points
13,104 views
0 votes
1 answer

How to install pip with Python 3?

If you're running Python 2.7.9+ or Python ...READ MORE

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

Calculator Project in Python

Hello all, I am a new in Python ...READ MORE

Feb 12, 2021 in Python by Gulshan

edited Mar 4 22 views
+1 vote
1 answer

ImportError: DLL load failed: The specified module could not be found.

Hi@akhtar, You may get this error if you ...READ MORE

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

How can I safely create a nested directory?

Python 3.5+: import pathlib pathlib.Path('/my/directory').mkdir(parents=True, exist_ok=True) pathlib.Path.mkdir as used above ...READ MORE

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

How to drop all tables from the database with manage.py CLI in Django?

Hello @kartik, Python you can write your own ...READ MORE

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

Error when running pip install: python setup.py egg_info"

ERROR: Command errored out with exit status ...READ MORE

Oct 29, 2020 in Python by anonymous
5,202 views
0 votes
1 answer

How to declare an array in Python?

variable = [] Now variable refers to an empty list*. Of ...READ MORE

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