Trending questions in Python

0 votes
2 answers

How can I rename multiple files in a certain directory using Python?

import os from optparse import OptionParser, Option class MyOption ...READ MORE

Jul 29, 2020 in Python by The real slim shady
4,769 views
0 votes
1 answer

flush parameter of print in Python

Usually all I/Os are buffered, meaning they ...READ MORE

Jul 30, 2019 in Python by Wajiha
• 1,960 points
7,289 views
0 votes
4 answers

How to write a single program in python to print different '*' triangles?

If you want to use the same ...READ MORE

Jun 11, 2019 in Python by Likhith
9,329 views
0 votes
1 answer

Closest value and its index in a sorted list - Python

You can try this @Mahesh: lst = [ ...READ MORE

May 28, 2019 in Python by Sai
9,909 views
+1 vote
1 answer

How to save a bitmap or vector graphics image after creating a drawing with python's turtle module.

This worked for me: from Tkinter import * from ...READ MORE

Jul 6, 2019 in Python by Kyraa
8,141 views
+1 vote
2 answers

How to automate image upload from my computer to site using python-selenium?

Hey, this code worked for me: image_path=os.path.abspath('.\\folder1\\subfolder2\file1.jpg') driver.find_element_by_id("Id of ...READ MORE

Aug 19, 2019 in Python by Rishi
6,278 views
+5 votes
1 answer

Print the odd and even factors of a number in Python

x = int(input("Enter any number \n")) print("The factors ...READ MORE

Nov 19, 2018 in Python by Nabarupa
17,702 views
0 votes
1 answer

How to input optional arguments in python command line?

Please use this code. if len(sys.argv) == 2: first_log ...READ MORE

Jul 11, 2019 in Python by Suri
7,762 views
0 votes
1 answer

Now able to open multiple windows: selenium.common.exceptions.WebDriverException: invalid session id

You have initialized driver only once and ...READ MORE

Apr 6, 2019 in Python by James
11,904 views
0 votes
1 answer

Python Pandas: KeyError: False

The reason for this error is that ...READ MORE

May 8, 2019 in Python by Jimmy
10,416 views
+1 vote
1 answer

how do i get a optimal cutoff value(directly in the form of numeric) from roc curves?

The optimal CutOff value is the point ...READ MORE

Oct 17, 2019 in Python by Saira
3,381 views
0 votes
1 answer

converting timedelta to float

Use the following piece of code: x1=datetime.timedelta(days=3000, seconds=0, ...READ MORE

Aug 8, 2019 in Python by Wajiha
• 1,960 points
6,390 views
0 votes
1 answer

how to convert date field into UTC format (2019-10-29T19:20:30.45Z)

Hey, I think this should do what ...READ MORE

Oct 29, 2019 in Python by Niharika
2,779 views
0 votes
1 answer

Python error "'str' object has no attribute 'turtle' in Python turtle"

There is a syntax error. Change the ...READ MORE

Jul 9, 2019 in Python by Pallavi
7,632 views
+1 vote
1 answer
+1 vote
0 answers

How to close a window, and then reinitialize it using PyQt

There is a button "btn_closeWin_and_reinit"  in the ...READ MORE

Jul 10, 2019 in Python by marceepoo
• 130 points

edited Jul 22, 2019 by Kalgi 7,489 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,890 views
0 votes
1 answer

Add header row in pandas dataframe while printing

Refer to this code: import pandas as pd col_name=['Name', ...READ MORE

Jul 5, 2019 in Python by Suri
7,633 views
+1 vote
0 answers

I have to write 2 triangles in one raw (python)

I have two triangles that has to ...READ MORE

Dec 4, 2019 in Python by מיקה
• 130 points
1,073 views
0 votes
1 answer

How to create LIST from CSV file in Python?

You can use the pandas library for this which ...READ MORE

Jul 15, 2019 in Python by Karan
7,154 views
0 votes
1 answer

How to write inline if statement for print in Python?

Inline if-else expression must always contain the else ...READ MORE

Dec 4, 2018 in Python by Nymeria
• 3,560 points

edited Dec 6, 2018 by Nymeria 16,780 views
+1 vote
1 answer

How do I use the data of an array after splitting it?

Hey, You can use  np.greater(b, f) np.greater_equal(b, f) np.less(b, f) np.less_equal(b, ...READ MORE

Dec 9, 2019 in Python by Payal
753 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,851 views
+3 votes
7 answers

How can I rename a file in Python?

yes, you can use "os.rename" for that. ...READ MORE

Mar 31, 2018 in Python by DareDev
• 6,890 points
20,107 views
+1 vote
1 answer

How can I delete a file in Python IDLE?

Hey @Starsarwar You have two different codes, they ...READ MORE

Oct 28, 2019 in Python by Kalgi
• 52,350 points
2,494 views
0 votes
1 answer

ProgrammingError: not all arguments converted during string formatting

Sorted!!!! just found the solution, 1 - apparently ...READ MORE

Sep 10, 2018 in Python by Priyaj
• 58,020 points
20,340 views
0 votes
1 answer

How can I use the sleep function in a python program?

You can use sleep as below. import time print(" ...READ MORE

Jun 10, 2020 in Python by anonymous
1,020 views
0 votes
2 answers

Difference between sort and sorted

when to use which? Use list.sort when you ...READ MORE

Mar 26, 2020 in Python by rahul
• 360 points
4,767 views
0 votes
2 answers

Change the default indexing of an array in pandas

df = pd.DataFrame({'month': [1, 4, 7, 10],                    'year': ...READ MORE

Nov 28, 2019 in Python by nagendra reddy
1,185 views
0 votes
1 answer

Python error "ZeroDivisionError: division by zero"

Catch the error and handle it: try: ...READ MORE

May 31, 2019 in Python by Rhea
8,749 views
0 votes
0 answers

I am trying to click the button but it is not working and it is drop list ..

<a class="quickreports btn btn3d tbbtn" href="javascript:" style="position:static" ...READ MORE

Dec 2, 2019 in Python by anonymous
• 120 points
833 views
0 votes
2 answers

Explain OOPs concept in python with programatic examples

OOP reflects the real world behavior of ...READ MORE

Jun 24, 2020 in Python by rahul
• 360 points
1,877 views
0 votes
0 answers

How to read data using popen?

I have written below code and its ...READ MORE

Aug 19, 2019 in Python by anonymous
5,291 views
0 votes
1 answer

Handling request exceptions while using threads?

There are different places you can add ...READ MORE

Nov 4, 2019 in Python by Richard
1,922 views
0 votes
1 answer

How can i import json file and encrypt it by using ASE MODE CBC encryption ?

Hi @Ahmed. Here's a sample code that ...READ MORE

Aug 20, 2019 in Python by Simran
5,212 views
+1 vote
2 answers

how can i do a binary search in python?

def Binary_search (array , element):       ...READ MORE

Jul 10, 2020 in Python by anonymous
• 240 points
1,127 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,413 views
+1 vote
0 answers

Sum the values of column matching and not matching from a .txt file and write output to a two different files using Python

Name                                                    value DR_CNDAOFSZAPZP_GPFS_VOL.0 139264 DR_CNDAOFSZAPZP_GPFS_VOL.1 15657 DR_CNDAOFSZAPZP_GPFS_VOL.0 139264 DR_CNDAOFSZAPZP_GPFS_VOL.1 156579 DR_CNDAOFSZAPZP_GPFS_VOL.2 156579 DR_CNDAOFSZAPZP_GPFS_VOL.3 ...READ MORE

Nov 20, 2019 in Python by Sagar
• 130 points
1,224 views
0 votes
1 answer

How to get anchor tags of particular class using BeautifulSoup?

You can specify the class you want ...READ MORE

Apr 2, 2019 in Python by John
11,228 views
0 votes
1 answer

i am normalizing the data set iris in python and get the error ::TypeError: 'numpy.float64' object is not callable

TRY THIS   #Nomalisation for i in names:     print(i)   ...READ MORE

Aug 20, 2019 in Python by Noel Deepak Palle
5,994 views
+2 votes
0 answers

I don't want to seem like a begger, but I've been working on this code for the past 3 days and made 0 progress.

Basically, my code runs a turtle and ...READ MORE

Nov 26, 2019 in Python by Kyler
• 140 points
921 views
0 votes
4 answers

What is a Tuple in Python and how to use it?

Tuples  are a  Unchanging sequence of values, ...READ MORE

Jun 21, 2020 in Python by sahil
• 500 points
2,062 views
0 votes
1 answer

What is the difference between print and pprint in Python?

As per the documentation,  The pprint module provides a capability ...READ MORE

Jul 8, 2019 in Python by Arvind
• 3,050 points
6,964 views
0 votes
1 answer

How to create empty pandas dataframe only with column names?

You can do it like this: df=pd.DataFrame(columns=["Name","Old","Ne ...READ MORE

Apr 6, 2019 in Python by Hari
10,971 views
+1 vote
0 answers

ssh db connection using python2.7

I am supposed to use python 2.7 ...READ MORE

Nov 22, 2019 in Python by sweta
• 130 points
952 views
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
6,136 views
0 votes
1 answer

Python: is thread still running

The key is to start the thread ...READ MORE

Aug 5, 2019 in Python by SDeb
• 13,300 points
5,649 views
0 votes
1 answer

Can we access Outer class member from an Inner class in Python?

If you want to access outer class ...READ MORE

Feb 13, 2019 in Python by Omkar
• 69,220 points
13,113 views
0 votes
1 answer

Python code for printing the string without vowels using list comprehension

Hey @Anvit, you can use something like ...READ MORE

Jul 8, 2019 in Python by Rajeev
6,812 views