Most viewed questions in Python

0 votes
1 answer

How to check whether a pandas DataFrame is empty?

Hello @kartik, I use the len function. It's much faster ...READ MORE

Apr 23, 2020 in Python by Niroj
• 82,880 points
1,831 views
0 votes
0 answers

Java : Sort integer array without using Arrays.sort()

I have this assignment- Write java program ...READ MORE

Aug 2, 2022 in Python by krishna
• 2,820 points
1,830 views
0 votes
1 answer

Shorter way to write a Python for loop

You can use the enumerate iterator: for i, ...READ MORE

Jan 17, 2019 in Python by SDeb
• 13,300 points
1,828 views
0 votes
1 answer

How to create and read from a temporary file in Python?

Hi, there is a very simple solution ...READ MORE

Jan 29, 2019 in Python by Nymeria
• 3,560 points
1,826 views
0 votes
1 answer

Round columns in pandas dataframe

You can now, use round on dataframe The code will ...READ MORE

Jul 4, 2019 in Python by SDeb
• 13,300 points
1,821 views
0 votes
1 answer

How to iterate a Json file which has multiple key value pairs and also nested list as part of the file?

I think you need to create some ...READ MORE

Nov 10, 2020 in Python by Gitika
• 65,910 points
1,816 views
0 votes
1 answer

Is there an expression for an infinite generator in Python?

you can iterate over a callable returning ...READ MORE

Nov 20, 2018 in Python by Nymeria
• 3,560 points
1,812 views
0 votes
1 answer

What is the purpose of else part in python exception handling?

When an error occurs, or exception as ...READ MORE

Aug 23, 2019 in Python by Arvind
• 3,040 points
1,808 views
0 votes
2 answers

How can I install external binaries using portable python

0110100001000101001010101001011010100100111100101001 READ MORE

Jan 24, 2019 in Python by anonymous
1,808 views
0 votes
1 answer

How to go to top frame in pdb (python debugger)

You can use a PdbExtension for this. See https://github.com/fschulze/pytest-pdb/pull/5 where ...READ MORE

Apr 30, 2019 in Python by SDeb
• 13,300 points
1,806 views
0 votes
1 answer

How to get status code from Python Requests?

Here's how you can get the status ...READ MORE

May 14, 2019 in Python by Rasheed
1,805 views
0 votes
1 answer

Plot correlation matrix using pandas

Just use pyplot.matshow() from matplotlib: import matplotlib.pyplot as plt plt.matshow(dataframe.corr()) plt.show() If df.corr() ...READ MORE

Apr 28, 2022 in Python by narikkadan
• 63,700 points
1,802 views
0 votes
1 answer

Python code Tic Tac Toe game

You could use random.shuffle from random import shuffle players ...READ MORE

May 28, 2019 in Python by Idam
1,802 views
0 votes
1 answer

How can I enable CORS on Django REST Framework

Hello @kartik, You can do by using a ...READ MORE

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

How to create a function like f(y) = xy^2 in Python?

This is very easy. have a look ...READ MORE

Aug 5, 2019 in Python by Neel
• 3,020 points

edited Aug 6, 2019 by Kalgi 1,785 views
0 votes
1 answer

What does the inplace function does in drop() and dropna() functions?

When inplace=True is passed, the data is renamed in ...READ MORE

Jul 5, 2019 in Python by Wasim
1,781 views
0 votes
1 answer

How to install Python MySQLdb module using pip?

It's easy to do, but hard to ...READ MORE

Aug 20, 2018 in Python by charlie_brown
• 7,720 points
1,779 views
0 votes
1 answer

Pyomo parallel processing to solve an instance

Depends on the solver and the model. ...READ MORE

Sep 21, 2018 in Python by Priyaj
• 58,090 points
1,778 views
0 votes
0 answers

re.sub erroring with "Expected string or bytes-like object"

I tried looping through my function but ...READ MORE

May 7, 2022 in Python by narikkadan
• 63,700 points
1,776 views
0 votes
1 answer

How to find all tags and strings in a document using find_next()?

You can use the find_all_next() to do this. Try ...READ MORE

May 14, 2019 in Python by Robin
1,776 views
0 votes
1 answer

Whenever you exit Python, is all memory de-allocated?

The answer here is no. The modules ...READ MORE

Jul 20, 2018 in Python by Priyaj
• 58,090 points
1,776 views
0 votes
1 answer

How can I use indices in math using python

Operator ^ is a bitwise operator, which does "bitwise exclusive or". More: http://wiki.python.org/moin/BitwiseOperators The ...READ MORE

Dec 11, 2018 in Python by aryya
• 7,450 points
1,775 views
0 votes
1 answer

Python error "AttributeError: incompatible shape for a non-contiguous array"

It is not always possible to change ...READ MORE

May 29, 2019 in Python by Imran
1,772 views
0 votes
2 answers

Why do we use return statement in python?

def maximum(x, y):     if x > y:     ...READ MORE

Apr 4, 2019 in Python by anonymous
1,771 views
0 votes
1 answer

Error:IntegrityError: (1062, "Duplicate entry '1-1-1' for key 'CSID'")

Hello @kartik, Changing index name in ./manage.py sqlall output. You could ...READ MORE

Jul 3, 2020 in Python by Niroj
• 82,880 points
1,769 views
0 votes
1 answer

An example showing how to plot the coherence of two signals

This should work well: import numpy as np import ...READ MORE

May 27, 2019 in Python by anonymous

edited May 27, 2019 by Kalgi 1,766 views
0 votes
0 answers

Python 3 ImportError: No module named 'ConfigParser'

I want to pip - install the ...READ MORE

Apr 24, 2022 in Python by Kichu
• 19,050 points
1,763 views
0 votes
1 answer

Error :on installing matplotlib

Hello @kartik, You had to install libfreetype6-dev and libpng-dev from the repositories. ...READ MORE

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

How can I Get Laplacian pyramid using opencv

As far as I can see you ...READ MORE

Sep 4, 2018 in Python by Priyaj
• 58,090 points
1,760 views
0 votes
3 answers

How to get the current time in Python

FOLLOWING WAY TO FIND CURRENT TIME IN ...READ MORE

Apr 8, 2019 in Python by rajesh
• 1,270 points
1,758 views
+1 vote
1 answer

How to check if a string is in a file, using python?

Hi, Try the below given code: with open('myfile.txt') as ...READ MORE

Jul 5, 2019 in Python by Shabnam
• 930 points
1,754 views
+1 vote
1 answer
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,880 points
1,751 views
0 votes
0 answers

How i can print and count all the all element when i search like " Automation step by step" in Google using python selenium

I am trying to count all the ...READ MORE

Jul 9, 2019 in Python by anonymous
• 120 points
1,749 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,748 views
0 votes
1 answer

Slicing a list using a variable, in Python

Yes its possible. Use the following piece ...READ MORE

Jul 2, 2019 in Python by Wajiha
• 1,950 points
1,745 views
0 votes
1 answer

How to find if setuptools is installed in python?

You can use python interpreter to check ...READ MORE

Jan 29, 2019 in Python by Omkar
• 69,230 points
1,745 views
0 votes
1 answer

AssertionError: <class 'numpy.ndarray'>

Hi, @There, The traceback module and sys.exc_info are ...READ MORE

Oct 19, 2020 in Python by anonymous
• 65,910 points
1,737 views
0 votes
1 answer

How to install PyInstaller?

Hey @Vedant, yes its easier to install ...READ MORE

Jul 4, 2019 in Python by Pooja
1,736 views
+4 votes
8 answers

How can I use Python's range function?

The range function is mostly used in for-loop.  Ex: for ...READ MORE

Aug 21, 2018 in Python by Omkar
• 69,230 points
1,736 views
0 votes
1 answer

How to Parse values from a JSON file?

import json from pprint import pprint with open('data.json') as ...READ MORE

Oct 15, 2018 in Python by Priyaj
• 58,090 points
1,733 views
0 votes
1 answer

How to resolve the error while importing cv2 from openCV in python?

I would recommend you go with anaconda ...READ MORE

Jul 31, 2019 in Python by Mohammad
• 3,230 points
1,732 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,729 views
0 votes
1 answer

What is .pydistutils.cfg?

I don't immediately see a reason why ...READ MORE

Jan 21, 2019 in Python by SDeb
• 13,300 points
1,728 views
0 votes
1 answer

Change the snake head color using python turtle

You can et the snakehead color by ...READ MORE

Jun 19, 2019 in Python by Faiza
1,722 views
0 votes
1 answer

How to convert doc file into pdf using python?

A simple example using com types, converting ...READ MORE

Nov 4, 2020 in Python by Gitika
• 65,910 points
1,716 views
0 votes
1 answer

When I create and remove files rapidly on windows using python I get WindowsError (Error 5)

Here's the short answer: disable any antivirus or ...READ MORE

Aug 31, 2018 in Python by charlie_brown
• 7,720 points
1,714 views
0 votes
1 answer

How to import json file to mongodb using pyspark (or python)?

You can use the same format as ...READ MORE

Sep 9, 2019 in Python by Karan
1,711 views