Most viewed questions in Python

0 votes
2 answers

Python error “ImportError: No module named”

use the dir() function for particular import ...READ MORE

Jun 6, 2020 in Python by sahil
• 580 points
15,575 views
0 votes
1 answer

Error:Django TemplateSyntaxError - 'staticfiles' is not a registered tag library

Hello @kartik, Try {% load static %} instead of {% load ...READ MORE

Jul 29, 2020 in Python by Niroj
• 82,880 points
15,484 views
0 votes
1 answer

Python Pandas Dataframe: set_value is deprecated and will be removed in a future release

The set_value function is deprecated and you will ...READ MORE

Apr 8, 2019 in Python by Jai
15,435 views
0 votes
1 answer

How to add multiple columns to pandas dataframe in one assignment?

Hello @kartik, You could use assign with a dict of ...READ MORE

Jun 15, 2020 in Python by Niroj
• 82,880 points
15,311 views
0 votes
1 answer

'python' is not recognized as an internal or external command

There are multiple ways you can use: 1)Use ...READ MORE

Feb 16, 2022 in Python by Nandini
• 5,480 points
15,282 views
0 votes
1 answer

How to I clear Tkinter Canvas using Python?

To clear a canvas, use the delete method.  This ensures ...READ MORE

Dec 24, 2018 in Python by Nymeria
• 3,560 points
15,187 views
+1 vote
2 answers

Python error "Python: can't assign to literal"

The way you're assigning variables is not ...READ MORE

Jun 17, 2019 in Python by Priya
15,071 views
0 votes
1 answer

How does numpy.newaxis work and when to use it?

Hello, The np.newaxis is generally used with slicing. It indicates ...READ MORE

Apr 14, 2020 in Python by Niroj
• 82,880 points
15,050 views
0 votes
1 answer

What is the difference between read() and readline() in python?

The read() will read the whole file at ...READ MORE

Apr 28, 2022 in Python by narikkadan
• 63,420 points
15,045 views
+1 vote
1 answer

module 'numpy' has no attribute 'unit8'

Hi@akhtar, You have used unit8 in your code. ...READ MORE

Jun 23, 2020 in Python by MD
• 95,440 points
15,031 views
0 votes
1 answer

Boto3 S3, sort bucket by last modified

I tried the following method. Its not 100% ...READ MORE

Jun 4, 2019 in Python by SDeb
• 13,300 points
14,893 views
0 votes
1 answer

Model Form “object has no attribute 'cleaned_data'” in Django?

Hello @kartik, For some reason, you're re-instantiating the ...READ MORE

Apr 29, 2020 in Python by Niroj
• 82,880 points
14,825 views
0 votes
1 answer

How to PATCH a single field using Django Rest Framework?

Hello @kartik, Serializers allow partial updates by specifying partial=True when initializing ...READ MORE

Jun 25, 2020 in Python by Niroj
• 82,880 points
14,803 views
+3 votes
5 answers

How to read multiple data files in python

Firstly we will import pandas to read ...READ MORE

Apr 6, 2018 in Python by DeepCoder786
• 1,720 points
14,795 views
0 votes
1 answer

'utf-8' codec can't decode byte 0x82 in position 16: invalid start byte

Hi@zena, The error is because there is some non-ASCII ...READ MORE

Jun 29, 2020 in Python by MD
• 95,440 points
14,762 views
0 votes
1 answer

ModuleNotFoundError: No module named 'sqlalchemy'

Hi@akhtar, You need to install sqlalchemy module in your condo ...READ MORE

Jun 26, 2020 in Python by MD
• 95,440 points
14,729 views
0 votes
1 answer

Comparing two files contents in python

Considering your file "Unique.txt" does just containt the IP ...READ MORE

Sep 20, 2018 in Python by Priyaj
• 58,090 points
14,717 views
0 votes
1 answer

Error:No module named MySQLdb

Hii @kartik, Try this code: pip install PyMySQL and then ...READ MORE

Jun 26, 2020 in Python by Niroj
• 82,880 points
14,701 views
0 votes
1 answer

How to remove a project from Pycharm?

Assuming that you have the project opened ...READ MORE

Aug 2, 2019 in Python by Arvind
• 3,040 points
14,649 views
–1 vote
1 answer

nmap.nmap.PortScannerError: 'nmap program was not found in path

python-nmap module used in python happens to use nmap binary ...READ MORE

Jan 30, 2019 in Python by Omkar
• 69,210 points
14,645 views
0 votes
1 answer

Python code to send an email with an attachment

Hi @Vipul, try out this code. I've ...READ MORE

Jun 11, 2019 in Python by Adil
14,540 views
0 votes
1 answer

How to append dataframe without index?

You have to use the ignore_index option. ...READ MORE

Apr 1, 2019 in Python by Robert
14,509 views
0 votes
1 answer

How to load python script in Jupyter Notebook?

Hi@akhtar, Starting from IPython 3 (now Jupyter project), ...READ MORE

Aug 17, 2020 in Python by MD
• 95,440 points
14,417 views
0 votes
1 answer

Run a function after keyboard interrupt in python

Below is the code to run a ...READ MORE

Jul 26, 2019 in Python by Shri
14,398 views
0 votes
1 answer

Error:mysql_config not found when installing mysqldb python interface

Hello @kartik, MySQLdb is a python interface for ...READ MORE

May 27, 2020 in Python by Niroj
• 82,880 points
14,329 views
+1 vote
1 answer

Error:Pandas read_csv low_memory and dtype options

Hello @kartik, Try this: dashboard_df = pd.read_csv(p_file, sep=',', error_bad_lines=False, ...READ MORE

Jun 22, 2020 in Python by Niroj
• 82,880 points
14,266 views
0 votes
1 answer

How to check if an element is present in a Django queryset?

Hello @kartik, You can use the following code: if ...READ MORE

May 27, 2020 in Python by Niroj
• 82,880 points
14,228 views
+1 vote
1 answer

How to create a file and save it to a model's FileField in Django?

Hello @kartik, Basically, a field declared as a FileField, ...READ MORE

Jun 30, 2020 in Python by Niroj
• 82,880 points
14,090 views
0 votes
1 answer

Python error "TypeError: 'encoding' is an invalid keyword argument for this function"

Trying using the io module for this ...READ MORE

Aug 2, 2019 in Python by Vaishali

edited Oct 7, 2021 by Sarfaraz 14,058 views
0 votes
2 answers

How to check if a csv file is empty in pandas?

Try this: df = pd.DataFrame(columns=['Name', 'ID', 'Department']) if df.empty ...READ MORE

Jul 1, 2019 in Python by Bob
14,050 views
0 votes
1 answer

1 Year Rolling mean pandas on column date

I believe this should work for you: # ...READ MORE

Sep 6, 2018 in Python by Priyaj
• 58,090 points
14,038 views
0 votes
1 answer

python error "AttributeError: 'NoneType' object has no attribute 'read'"

The microphone needs to be entered using ...READ MORE

Oct 3, 2019 in Python by Jack
13,962 views
0 votes
1 answer

How to use Django variable in JavaScript file?

Hello @kartik, You need to print it before ...READ MORE

Jul 29, 2020 in Python by Niroj
• 82,880 points
13,955 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,846 views
0 votes
1 answer

timedelta in years

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
13,837 views
0 votes
1 answer

How to use multiprocessing pool.map with multiple arguments?

The answer to this is version- and ...READ MORE

Nov 19, 2020 in Python by Gitika
• 65,910 points
13,726 views
0 votes
1 answer

SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape

This error occurs because you are using ...READ MORE

Sep 9, 2020 in Python by Gitika
• 65,910 points
13,672 views
0 votes
1 answer

How to replace entire column in pandas dataframe?

Use the dataframe with respective column names ...READ MORE

May 8, 2019 in Python by John
13,546 views
0 votes
1 answer

Error: port is already in use of Django Server

Hii @kartik, Just type sudo fuser -k 8000/tcp. This ...READ MORE

May 6, 2020 in Python by Niroj
• 82,880 points
13,545 views
0 votes
1 answer

How to open another window using PyQt

Switch between self.hide() and self.showMinimized() def start(self): ...READ MORE

Oct 1, 2018 in Python by Priyaj
• 58,090 points
13,544 views
+1 vote
1 answer

'utf-8' codec can't decode byte 0xa9 in position 12527: invalid start byte

Hello, You can always safely read in binary ...READ MORE

Jun 30, 2020 in Python by Niroj
• 82,880 points
13,523 views
0 votes
1 answer

Execute PHP code in Python

Try the following Code: import subprocess # if the ...READ MORE

Dec 11, 2018 in Python by SDeb
• 13,300 points
13,433 views
0 votes
1 answer

TypeError: list indices must be integers or slices, not str

Hi@akhtar, As we know that the index of ...READ MORE

Oct 15, 2020 in Python by MD
• 95,440 points
13,412 views
0 votes
3 answers

Count the number occurrences of a character in a string

The string count() method returns the number of occurrences of ...READ MORE

Dec 28, 2020 in Python by Carlos
13,408 views
0 votes
1 answer

How do I use urllib to see if a website is 404 or 200 in Python?

For Python 3, try doing this: import urllib.request, ...READ MORE

Nov 29, 2018 in Python by Nymeria
• 3,560 points

edited Dec 11, 2018 by Nymeria 13,386 views
0 votes
2 answers

Python Error "UnicodeEncodeError: 'ascii' codec can't encode character u'\u03b1' in position 20: ordinal not in range(128)"

import csv import sys reload(sys) sys.setdefaultencoding('utf8') data = [["a", "b", u'\xe9']] with ...READ MORE

Jun 28, 2019 in Python by anonymous
13,307 views
0 votes
1 answer

ImportError: No module named pip when trying to install packages

Hello @kartik, I found that on Ubuntu, pip ...READ MORE

May 27, 2020 in Python by Niroj
• 82,880 points
13,278 views
0 votes
1 answer

Python datetime: How to change month number to month name?

You can use the datetime module to ...READ MORE

May 9, 2019 in Python by Suman
13,168 views
0 votes
0 answers

How can I solve it? TypeError: unsupported operand type(s) for /: 'float' and 'list'

I am trying to calculate numerical integration ...READ MORE

Nov 17, 2020 in Python by asimsek
• 120 points
13,098 views
0 votes
1 answer

Python argparse error "NameError: name 'file' is not defined"

The right datatype for destination in argpasrse module ...READ MORE

Nov 28, 2018 in Python by Omkar
• 69,210 points
13,010 views