Trending questions in Python

0 votes
1 answer

Importing files from different folder in python.

By default, you can't. When importing a ...READ MORE

Dec 20, 2020 in Python by Nikita
3,755 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,840 points

edited Oct 7, 2021 by Sarfaraz 13,328 views
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,460 points
11,383 views
0 votes
1 answer

How do I update pip itself from inside my virtual environment?

Hello, pip is just a PyPI package like any other; you ...READ MORE

Nov 20, 2020 in Python by Niroj
• 82,840 points
4,975 views
+4 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
13,147 views
0 votes
1 answer

How to avoid missing module docstring in pylint?

Either write your docs or use a ...READ MORE

Nov 6, 2020 in Python by anonymous
• 65,770 points
5,535 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,840 points
13,379 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,840 points
11,161 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,770 points
11,199 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,770 points
5,447 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,770 points
4,032 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,770 points
2,913 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,840 points
10,978 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,840 points
10,831 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,840 points
8,772 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,840 points
10,848 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,770 points
4,149 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,840 points
12,763 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,438 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,770 points
2,435 views
0 votes
1 answer

Python: ImportError: No module named Crypto.Cipher

Seems like the pycrypto package is not ...READ MORE

Jul 31, 2019 in Python by Hari
25,064 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,840 points
4,097 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,118 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,105 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,604 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,617 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
810 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
24,694 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,551 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
1,953 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,420 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,523 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
1,906 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,536 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,016 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,401 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,187 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
7,972 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,401 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,560 views
0 votes
1 answer

Pandas df header on 2 row

By default when you import a file, ...READ MORE

Apr 4, 2019 in Python by Yogi
29,483 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,048 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
9,930 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,236 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,405 views
0 votes
1 answer

Distance calculator

Hello @ Try this code: import math x, y = ...READ MORE

Nov 13, 2020 in Python by Niroj
• 82,840 points
3,949 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,602 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,458 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,242 views