Most voted questions in Python

0 votes
1 answer

Read Nested Json as DataFrame

Here is the code for it. da=[ {"age":34, "id":1, "name":"Tony", "salary":1400, "dept_no":[10,20], "Cntct":{"Phone":[1234567890,9876543210], "state":"NY", ...READ MORE

Jul 25, 2019 in Python by Jimmy
5,849 views
0 votes
1 answer

How to print like printf in Python3?

To print like printf in Python you ...READ MORE

Jul 25, 2019 in Python by Wajiha
• 1,950 points
4,460 views
0 votes
1 answer

Is there an equivalent of C’s (?:) ternary operator in python?

Yes, there is. The syntax is as ...READ MORE

Jul 25, 2019 in Python by Alia
735 views
0 votes
1 answer

Copy object in Python

In general, copy.copy() or copy.deepcopy() works perfectly ...READ MORE

Jul 25, 2019 in Python by Tanishq
464 views
0 votes
1 answer

Callable objects approach vs nested scope approach to create higher order functions - python

Using callable objects has a disadvantage over ...READ MORE

Jul 25, 2019 in Python by Vivan
518 views
0 votes
1 answer

How do you make a higher order function in Python?

You have two choices to create higher-order ...READ MORE

Jul 25, 2019 in Python by Yesha
1,014 views
0 votes
1 answer

Why does changing one list, change another - Python

Hey @Aleesha, here when you write x=y, ...READ MORE

Jul 25, 2019 in Python by Kanika
2,263 views
0 votes
0 answers

pass optional or keyword parameters from one function to another in python?

How can I pass optional or keyword ...READ MORE

Jul 24, 2019 in Python by Hari
603 views
0 votes
1 answer

Why do lambdas defined in a loop with different values all return the same result?

Here x is not local to the ...READ MORE

Jul 24, 2019 in Python by Haseeb
1,067 views
0 votes
1 answer

Local and Global parameters rules - python

In python, variables that are only referenced ...READ MORE

Jul 24, 2019 in Python by Alia
453 views
0 votes
1 answer

Convert list into dict in Python

Try using the below-mentioned code, it should ...READ MORE

Jul 24, 2019 in Python by Banu
1,087 views
0 votes
1 answer

Python error "UnboundLocalError: local variable 'x' referenced before assignment"

You get this error because when you ...READ MORE

Jul 24, 2019 in Python by Greg
18,651 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,950 points
2,891 views
0 votes
1 answer

How to manipulate a numpy?

You can use the below code slice ...READ MORE

Jul 24, 2019 in Python by Hari
561 views
0 votes
1 answer

i had problem with selenium x path i make Facebook sharing script but he is not clicking share button? i'm using python

Hey Hazma, I tried running your code, ...READ MORE

Jul 26, 2019 in Python by Abha
• 28,140 points
2,584 views
0 votes
1 answer

How to eliminate out outliers in a dataframe?

There are various ways we can replace ...READ MORE

Jul 24, 2019 in Python by Shri
513 views
0 votes
0 answers

How do you install python 3.6 in linux?

I am having trouble choosing interpreter as ...READ MORE

Jul 24, 2019 in Python by Waseem
• 4,540 points
386 views
0 votes
0 answers

How do you install spyder on anaconda?

Is there a way to work with ...READ MORE

Jul 24, 2019 in Python by Waseem
• 4,540 points
505 views
0 votes
1 answer

Is it possible to create a dictionary with multiple keys for a single value?

One thing that you can do here ...READ MORE

Jul 24, 2019 in Python by Arvind
• 3,040 points
549 views
0 votes
1 answer

What is the use of '==' operator in dictionary in Python?

Yes you can use '==' operator to ...READ MORE

Jul 24, 2019 in Python by Arvind
• 3,040 points
545 views
0 votes
1 answer

Force Python Scrapy not to encode URL

When creating a Request object scrapy applies some url ...READ MORE

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

openssl_seal() in Python

I think it should be relatively straightforward ...READ MORE

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

Can I blindly jump into using docker in production?

Hey Jasmine If the question was can I ...READ MORE

Jul 23, 2019 in Python by Alia
495 views
0 votes
1 answer

Create vars based on number of elements on the list

Hey @Ashish, you can try something like ...READ MORE

Jul 23, 2019 in Python by Haseeb
361 views
0 votes
1 answer

How to print a string with curly braces in Python?

You can use something like this - mystring ...READ MORE

Jul 23, 2019 in Python by Neel
• 3,020 points
11,543 views
0 votes
1 answer

How to add elements to a list in Python?

To initialize an empty list do this: new_list ...READ MORE

Jul 23, 2019 in Python by Neel
• 3,020 points
518 views
0 votes
1 answer

Compress and decompress string in Python

You can use the zlib module available in ...READ MORE

Jul 23, 2019 in Python by Bhagavath

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

Convert string to unicode in Python

Suppose you have a string in ASCII form ...READ MORE

Jul 23, 2019 in Python by Gani
12,631 views
0 votes
2 answers

What is the python logic to check if a number is armstrong number or not?

a = int (input('enter number')) num = a sum ...READ MORE

Jul 16, 2020 in Python by amrut
• 240 points
1,328 views
0 votes
2 answers

How to define a class in python?

Class use the special word  class for declaration. ...READ MORE

Jun 6, 2020 in Python by anonymous
• 580 points
862 views
0 votes
1 answer

input() vs sys.stdin.read()

If you're on Windows, you'll notice that ...READ MORE

Jul 23, 2019 in Python by SDeb
• 13,300 points
6,109 views
0 votes
1 answer

Edit a function in Python IDLE

No, if you have readline support enabled, ...READ MORE

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

Create a database table using python

Hey @Kim, try something like this: import MySQLdb # ...READ MORE

Jul 23, 2019 in Python by Barbara
1,097 views
0 votes
1 answer

Open database connection - python

Hey you can use something like this: import ...READ MORE

Jul 23, 2019 in Python by Kyraa
611 views
0 votes
1 answer

Need help to open excel file and read in Python

You can use pandas module to do ...READ MORE

Jul 22, 2019 in Python by Tina
716 views
0 votes
1 answer

Install python using Ansible

Try something like: - hosts: all remote_user: ...READ MORE

Jul 22, 2019 in Python by Travis
8,447 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,547 views
0 votes
1 answer

How do I add a button - Python

Try this: # Import required packages import Tkinter import tkMessageBox top ...READ MORE

Jul 22, 2019 in Python by Ashish
370 views
0 votes
1 answer

Python error "'Series' object is not callable "

Try this: df['ln_returns'] = np.log(df['Close_mid']/df['Close_mid']) df['Close_mid'](1)) doesn't seem to ...READ MORE

Jul 22, 2019 in Python by Greg
17,142 views
0 votes
1 answer

Plot a pie-chart in Python in Matplotlib

Not sure which dataset you are using. ...READ MORE

Jul 22, 2019 in Python by Shri
6,292 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
2,707 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,950 points
3,947 views
0 votes
1 answer

Difference between ElementTree and Minidom

Python allows parsing these XML documents using ...READ MORE

Jul 22, 2019 in Python by Wajiha
• 1,950 points
5,179 views
0 votes
2 answers

How do you read from a file using file handling in python?

for write, read,append data in file check ...READ MORE

Jun 21, 2020 in Python by sahil
• 580 points
931 views
0 votes
0 answers

How to print square of first 100 natural numbers using iterations in python?

Can you make a program with nested ...READ MORE

Jul 22, 2019 in Python by Waseem
• 4,540 points
791 views
0 votes
1 answer

What are some good web crawlers in Python?

Following are the libraries that can help ...READ MORE

Jul 22, 2019 in Python by Arvind
• 3,040 points
560 views
0 votes
1 answer

How to iterate over a string when there is successive increase in its length?

The following code might help -  mystring = ...READ MORE

Jul 22, 2019 in Python by Arvind
• 3,040 points
424 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
2,842 views
0 votes
1 answer

USING LIKE inside pandas.query()

If you have to use df.query(), the ...READ MORE

Jul 22, 2019 in Python by SDeb
• 13,300 points
7,819 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,192 views