Trending questions in Python

0 votes
1 answer

Difference between function and generator?

Normal Functions vs Generator Functions: Generators in Python ...READ MORE

Jul 15, 2019 in Python by Wajiha
• 1,960 points
4,905 views
0 votes
1 answer

How to write a python script for downloading a video from YouTube and saving it to a directory?

First download pytube using the following code  pip ...READ MORE

Sep 4, 2019 in Python by Neel
• 3,020 points
2,684 views
0 votes
1 answer

Is it possible to find the source code of built-in functions of Python?

Since Python is open source you can ...READ MORE

Jul 17, 2019 in Python by Neel
• 3,020 points
4,780 views
0 votes
1 answer

How to write a regular expression to check whether an input is an identifier or not?

As per the documentation, an identifer can ...READ MORE

Aug 8, 2019 in Python by Neel
• 3,020 points
3,739 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
14,140 views
0 votes
1 answer

'NodeList' object has no attribute 'firstChild'

Use the following piece of code: from xml.dom ...READ MORE

Jul 22, 2019 in Python by Wajiha
• 1,960 points
4,447 views
0 votes
1 answer

How do I check if input string is a valid regular expression or not in Python?

Hi. Good question! Well, just like what ...READ MORE

Feb 12, 2019 in Python by Nymeria
• 3,560 points
11,292 views
+1 vote
2 answers

Python convert extracted excel file to csv

Some services require table data in CSV ...READ MORE

Aug 30, 2019 in Python by Mian Tanzeel
6,979 views
0 votes
1 answer

Python error "ValueError: size needs to be (int width, int height)" while using pygame.Surface

pygame.Surface takes in integer values for building ...READ MORE

Jun 19, 2019 in Python by Varsha
5,741 views
0 votes
1 answer

Python error "AttributeError: '_Screen' object has no attribute 'onkeypress'"

Instead of  wn.onkeypress(go_up, "w") Try wn.onkey(go_uo, " ...READ MORE

Jul 5, 2019 in Python by Pooja
5,085 views
0 votes
1 answer

How to suppress console output in Python?

You can try the following block of ...READ MORE

Jun 7, 2019 in Python by SDeb
• 13,300 points
6,158 views
0 votes
1 answer

How to find the greatest number in a list in Python?

1. By using max function -  highest = ...READ MORE

Aug 21, 2019 in Python by Neel
• 3,020 points
2,869 views
0 votes
1 answer

Installing package not found in conda

You can install pip in your conda env and then run pip ...READ MORE

Jul 31, 2019 in Python by SDeb
• 13,300 points
3,771 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
2,033 views
0 votes
1 answer

Can I build a plagiarism checker using python?

Hey @Alessha, you can use an SDK ...READ MORE

Aug 5, 2019 in Python by Kalgi
• 52,350 points
3,468 views
0 votes
2 answers

Manually raising (throwing) an exception in Python

Exception handling issues in python can easily ...READ MORE

Jan 18, 2019 in Python by nick
• 140 points
17,486 views
0 votes
1 answer

Install virtualenv - python

Follow these steps to install virtualenv on ...READ MORE

Oct 7, 2019 in Python by Harshit
733 views
0 votes
1 answer

What does AF_INET mean?

AF_INET refers to Address from the Internet ...READ MORE

Jul 3, 2019 in Python by Wajiha
• 1,960 points
4,765 views
0 votes
1 answer

better way to drop nan rows in pandas

Use dropna: dat.dropna() You can pass param how to drop if all ...READ MORE

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

Create an empty tkinter window - Python

Its pretty simple: # import the module import Tkinter $Create ...READ MORE

Jul 22, 2019 in Python by Aysha
3,882 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 14,036 views
0 votes
1 answer

How to pass query string in url using python requests?

You can pass the key-value pairs to ...READ MORE

May 14, 2019 in Python by Likith
6,886 views
0 votes
1 answer

How can I change the iteration variable inside a for loop in python?

Assume you have a list of lists: my_list ...READ MORE

Jun 10, 2019 in Python by Shubham Bansal
5,662 views
0 votes
1 answer

How to remove all characters before a specific character in Python?

Use re.sub. Just match all the chars ...READ MORE

Feb 27, 2019 in Python by SDeb
• 13,300 points
10,116 views
0 votes
1 answer

How to fill Null/NaN values in Pandas Dataframe?

Pandas allows you to change all the ...READ MORE

May 13, 2019 in Python by Rajat
6,861 views
0 votes
1 answer

Difference between a normal def defined function and lambda function in python?

Have a look at this code: # Python ...READ MORE

May 20, 2019 in Python by Trisha
6,520 views
0 votes
1 answer

how to find files and skip directories in os.listdir

You need to filter out directories; os.listdir() ...READ MORE

Mar 6, 2019 in Python by SDeb
• 13,300 points
9,751 views
0 votes
1 answer

How to get value in Pandas dataframe using index?

You can use the iloc method to do ...READ MORE

Apr 8, 2019 in Python by Rohit
8,306 views
0 votes
1 answer

Python Pandas: Find length of string in dataframe

You can find the length of the ...READ MORE

May 14, 2019 in Python by Firoz
6,747 views
0 votes
1 answer

Make turtle face a particular direction in python

You can use the the setheading command turtle.setheading(<degrees/radians>) In ...READ MORE

Jul 8, 2019 in Python by Jinu
4,337 views
0 votes
1 answer

How to open gmail and other menus from Google Apps menu using python selenium

You have to add implicit wait until ...READ MORE

Jul 31, 2019 in Python by Rishi
3,310 views
0 votes
1 answer

PyCharm type hinting weirdness

This looks like a bug in PyCharm. ...READ MORE

Jul 22, 2019 in Python by SDeb
• 13,300 points
3,702 views
0 votes
1 answer

How to convert pandas dataframe to numpy array?

Irrespective of whether the dataframe has similar ...READ MORE

May 13, 2019 in Python by Rishi
6,722 views
0 votes
1 answer

Performing divison on timedelta object in python?

Refer the following piece of code: e1=datetime.timedelta(days=32, seconds=0, ...READ MORE

Aug 13, 2019 in Python by Wajiha
• 1,960 points
2,714 views
0 votes
1 answer

What are first class objects in Python?

First-class objects in a language are handled uniformly ...READ MORE

Aug 2, 2019 in Python by Arvind
• 3,050 points
3,168 views
+2 votes
1 answer

Import zip files and process the excel files ( inside the zip files ) by using pyspark connecting with pymongo

I found this sample code: import zipfile import io def ...READ MORE

Aug 19, 2019 in Python by Reshma
2,439 views
+1 vote
1 answer

How to handle Real-Time Matplotlib Plotting

To draw a continuous set of random ...READ MORE

Sep 26, 2018 in Python by Priyaj
• 58,020 points
16,408 views
0 votes
1 answer

Writing output to new file using xml.etree.ElementTree in python

To write results to a new file, ...READ MORE

Jul 25, 2019 in Python by Wajiha
• 1,960 points
3,413 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,220 points
13,708 views
0 votes
1 answer

Python: Both list gets affected after creating list using list2 = list1

When you are copying a list to ...READ MORE

Aug 1, 2019 in Python by Lohit
3,084 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,050 points
2,040 views
0 votes
1 answer

What is the easiest way to concatenate two lists in Python?

You can use the + operator to combine them: list1 ...READ MORE

Sep 16, 2019 in Python by Neel
• 3,020 points
1,026 views
0 votes
1 answer

How I do get the data from the <font> tag from a given tr tag?

This should work: from bs4 import BeautifulSoup html_doc='''<tr id="tr_m_1570:240HJY" ...READ MORE

Sep 18, 2019 in Python by Omkar
• 69,220 points
872 views
0 votes
1 answer

Get bbox in data coordinates in matplotlib

I'm not sure how you got the ...READ MORE

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

How to read numbers from file in Python?

Assuming you don't have extraneous whitespace: with open('file') ...READ MORE

Apr 16, 2019 in Python by SDeb
• 13,300 points
7,498 views
0 votes
1 answer

Python Error "ERROR: PyQt4-4.11.4-cp27-cp27m-win32.whl is not a supported wheel on this platform."

cp27 means it's for python 2.7. Make ...READ MORE

Jul 22, 2019 in Python by Greg
3,296 views
0 votes
1 answer

Sort list by frequency in python

You can try the following for a ...READ MORE

May 13, 2019 in Python by SDeb
• 13,300 points
6,291 views
+1 vote
0 answers
0 votes
2 answers

How to implement Stack in python

There are different method to implement stack ...READ MORE

Jun 21, 2020 in Python by pagarsach
• 160 points
1,353 views
0 votes
1 answer

Python error "_tkinter.TclError: unknown font style "Normal""

Change the line  pen.write("score: {} High Score: {}".format(score, ...READ MORE

Jul 22, 2019 in Python by Yashita
3,240 views