Trending questions in Python

0 votes
1 answer

How to convert CSV file to JSON file using Pandas?

Hi@akhtar, You can convert your CSV file to ...READ MORE

Jun 25, 2020 in Python by MD
• 95,440 points
10,800 views
0 votes
1 answer

How to return custom JSON in Django REST Framework?

Hello @kartik, There are 2 ways to custom ...READ MORE

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

How to Install Python packages from local file system folder to virtualenv with pip?

Hello @kartik, You can try the code below: pip ...READ MORE

May 12, 2020 in Python by Niroj
• 82,880 points

edited Oct 7, 2021 by Sarfaraz 12,714 views
0 votes
1 answer

AttributeError: type object 'numpy.ndarray' has no attribute '__array_function__'

Hi@akhtar, I think numpy version is not compatible ...READ MORE

Apr 13, 2020 in Python by MD
• 95,440 points
13,834 views
0 votes
1 answer

How to load Numpy array in Jupyter Notebook?

Hi@akhtar, You can use numpy.load() function to load ...READ MORE

Jun 22, 2020 in Python by MD
• 95,440 points
10,754 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,656 views
0 votes
1 answer

Error: Catch a thread's exception in the caller thread in Python

The problem is that thread_obj.start() returns immediately. The child ...READ MORE

Nov 2, 2020 in Python by Gitika
• 65,910 points
4,996 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,908 views
0 votes
1 answer

Running shell command and capturing the output

Modern versions of Python (3.5 or higher): run If ...READ MORE

Dec 28, 2020 in Python by Gitika
• 65,910 points
2,539 views
0 votes
1 answer

Error: No module named 'django.core.urlresolvers'

Hello @kartik, If you want to import reverse, ...READ MORE

Aug 5, 2020 in Python by Niroj
• 82,880 points
8,716 views
+3 votes
2 answers

sum of 1/2+2/3+3/4+...+n/n+1

num = int(input("Enter a number: ")) newnum = ...READ MORE

Dec 27, 2019 in Python by Nisha
• 200 points
12,298 views
0 votes
2 answers

Deleting DataFrame row in Pandas based on column value

Pandas provide data analysts a way to ...READ MORE

Jan 4, 2021 in Python by Nikita
2,065 views
0 votes
1 answer

What is `related_name` used for in Django?

Hello @kartik, The related_name attribute specifies the name of the ...READ MORE

Jun 26, 2020 in Python by Niroj
• 82,880 points
10,372 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
2,869 views
0 votes
1 answer

Error:django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb

Hello @kartik, It looks like you don't have ...READ MORE

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

How to perform HTML decoding/encoding using Python/Django?

Hello, For html encoding, there's cgi.escape from the standard library: >> ...READ MORE

May 7, 2020 in Python by Niroj
• 82,880 points
12,500 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
652 views
0 votes
1 answer

What is the purpose of ​#!/usr/bin/python​on the first line in the above code?

Hey, @Roshni, By specifying #!/usr/bin/python you specify exactly ...READ MORE

Jun 23, 2020 in Python by Gitika
• 65,910 points
10,379 views
0 votes
1 answer

Import error: No module name urllib2

As stated in the urllib2 documentation: The urllib2 module has been split ...READ MORE

May 11, 2020 in Python by Niroj
• 82,880 points
12,233 views
0 votes
1 answer

How to disable a method in a ViewSet, django-rest-framework

Hello @kartik, You could keep using viewsets.ModelViewSet and define http_method_names on your ...READ MORE

Jun 26, 2020 in Python by Niroj
• 82,880 points
10,204 views
0 votes
2 answers

AttributeError: '<invalid type>' object has no attribute 'pen' on line 2

Hello, Turtle.pen is used to set/get pen attributes ...READ MORE

Nov 25, 2020 in Python by Niroj
• 82,880 points
3,558 views
0 votes
1 answer

How to send a correct authorization header for basic authentication

Hello @kartik, Here is how to do Basic ...READ MORE

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

Creating an empty Pandas DataFrame, then filling it?

Here's a couple of suggestions: Use date_range for the index: import ...READ MORE

Jan 5, 2021 in Python by Gitika
• 65,910 points
1,804 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,910 points
3,235 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,880 points
6,689 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,327 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,910 points
1,700 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,910 points
1,687 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,440 points
5,087 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,440 points
1,894 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
1,700 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,001 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,910 points
3,881 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,910 points
4,982 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,910 points
2,248 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,880 points
8,013 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,880 points
8,101 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,880 points
11,000 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,910 points
1,341 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,880 points
7,428 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,880 points
9,822 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
21,867 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
34,820 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,910 points
1,210 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,950 points
23,874 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,880 points
9,387 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 11,586 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,880 points
7,196 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,880 points
9,136 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,910 points
1,063 views