Trending questions in Python

0 votes
1 answer

What is the easiest way to implement 'IN' and 'NOT IN' in Pandas dataframe?

You can use pd.Series.isin. For "IN" use: something.isin(somewhere) Or for "NOT ...READ MORE

Aug 23, 2019 in Python by Arvind
• 3,040 points
12,568 views
0 votes
1 answer

How to keep keys/values in same order as declared?

Hello @kartik, Dictionaries will use an order that ...READ MORE

Apr 30, 2020 in Python by Niroj
• 82,880 points
1,674 views
0 votes
1 answer

How to convert one list into generator?

Hi@akhtar, Say, you have one list A. Now convert ...READ MORE

Apr 23, 2020 in Python by MD
• 95,440 points
1,968 views
0 votes
0 answers

I am trying to build a pong game this is what they showed me.

import turtle wn = turtle.Screen() wn.bgcolor("blue") wn.tracer(0) #Paddle A paddle_a = turtle.Turtle() paddle_a.speed(0) paddle_a.shape("square") paddle_a.color("red") paddle_a.ShapeSize paddle_a.penup() paddle_a.goto(-350, ...READ MORE

May 23, 2020 in Python by Praise
• 120 points

edited May 25, 2020 by Gitika 599 views
0 votes
0 answers

How do I fix this Set function in python?

I have the following code below I ...READ MORE

May 20, 2020 in Python by Olufemiodubote
• 120 points
717 views
0 votes
1 answer

How do I log a Python error with debug information?

Hii, In most applications, you won't be calling ...READ MORE

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

How can I save a final model after training it on chunks of data?

Hey, @Anan, When you specify chunk size in a ...READ MORE

Apr 15, 2020 in Python by Gitika
• 65,910 points
2,148 views
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,801 views
0 votes
1 answer

Error:Installation Issue with matplotlib Python

Hii @kartik, I assume you have installed the ...READ MORE

May 7, 2020 in Python by Niroj
• 82,880 points
1,189 views
+1 vote
0 answers

TypeError: only integer scalar arrays can be converted to a scalar index

import cv2 import numpy as np import matplotlib.pyplot as ...READ MORE

Dec 18, 2019 in Python by sandeep
• 130 points
7,192 views
0 votes
1 answer

AttributeError: 'module' object has no attribute 'HTTPSConnection'

Hi@akhtar, You have to install openssl and openssl-devel before ...READ MORE

Apr 20, 2020 in Python by MD
• 95,440 points
1,831 views
0 votes
1 answer

how to run test cases of different modules with same marker at a time using pytest

Hey,@Nikitha, Suppose you have multiple files say test_sample1.py, test_sample2.py. To ...READ MORE

Apr 28, 2020 in Python by Gitika
• 65,910 points
1,483 views
+1 vote
1 answer

Want to know how to write paragraph on image using pillow python?

Hi, @Shantanu, You can make use of the ...READ MORE

Apr 14, 2020 in Python by Gitika
• 65,910 points
2,026 views
0 votes
1 answer

How to unzip a list of tuples into individual lists?

Hello @kartik, zip is its own inverse! Provided you ...READ MORE

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

How can we remove an element from dic type variables. Eg : a={'A' : 2 , 'K' : 4 , 'D' : 6} }

Hey, @Kanishka, Suppose your dict contains: a={'A' : 2 ...READ MORE

May 20, 2020 in Python by Gitika
• 65,910 points
449 views
0 votes
1 answer

web scraping using python

Hey, @Pythonist, You can try this, ##################################### Method 1 import ...READ MORE

May 6, 2020 in Python by Gitika
• 65,910 points
1,061 views
0 votes
1 answer

Error:Render form errors with the label rather than field name

Hello @kartik, There is a simple way to ...READ MORE

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

How to clone or copy a list?

Hello @kartik, With new_list = my_list, you don't actually ...READ MORE

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

ImportError: matplotlib requires dateutil"

Hi@akhtar, The dateutil module provides powerful extensions to the standard ...READ MORE

Apr 9, 2020 in Python by MD
• 95,440 points
2,142 views
0 votes
1 answer

I am trying to install visualize on my python 3.8 but i end up with the followinf error.

Hi@Avinash, I think the module name is visualization ...READ MORE

Apr 27, 2020 in Python by MD
• 95,440 points
1,377 views
0 votes
1 answer

I want to download a file from the website by web scraping. Can anyone explain how to do this in jupyter lab (python) with an example?

Hey, Web scraping is a technique to automatically ...READ MORE

Apr 7, 2020 in Python by Gitika
• 65,910 points
2,115 views
0 votes
1 answer

TypeError: unsupported operand type(s) for -: 'list' and 'int'

Hey, @William For me the code is working ...READ MORE

Mar 11, 2020 in Python by Roshni
• 10,520 points
3,281 views
0 votes
2 answers

Replacements for switch statement in Python?

The recommended path for Python 3.10 which ...READ MORE

Feb 9, 2022 in Python by Soham
• 9,700 points
599 views
0 votes
1 answer

How can I find script's directory with Python?

Hii, You need to call os.path.realpath on __file__, so that when __file__ is ...READ MORE

May 11, 2020 in Python by Niroj
• 82,880 points
603 views
0 votes
0 answers

name error: name 'symtr' is not globally defined

class Solution(object):     def symtr(self,root1, root2):         if(root1==None and root2==None):             return True         elif(root1==None ...READ MORE

May 14, 2020 in Python by anonymous
• 120 points
508 views
0 votes
0 answers

Find all the classes of the table tags

Create a nested list containing classes of ...READ MORE

Apr 24, 2020 in Python by Abhishek
• 120 points
1,356 views
0 votes
0 answers

I am trying to install pyknow but i get this error

could not find a version that  satisfies ...READ MORE

Mar 4, 2020 in Python by Maria
• 120 points
3,494 views
0 votes
0 answers

I am trying to install PyBase64 on my python 3.8. But I end up with the following error:

$ pip install pybase ERROR: Could not find ...READ MORE

Mar 24, 2020 in Python by Nishant
• 210 points
2,631 views
0 votes
1 answer

How to configure smtp server using python?

Hi@akhtar, To set smtp server in your system, ...READ MORE

Apr 15, 2020 in Python by MD
• 95,440 points
1,625 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,062 views
0 votes
1 answer

How to create a zip archive of a directory in Python?

Hello @kartik, The easiest way is to use shutil.make_archive. ...READ MORE

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

DatabaseError: current transaction is aborted, commands ignored until end of transaction block?

Hello @kartik, To get rid of the error, roll ...READ MORE

May 6, 2020 in Python by Niroj
• 82,880 points
654 views
0 votes
2 answers

Is it possible to launch python idle from a virtual environment?

Try running the following code. #!/usr/bin/env python """Simple script ...READ MORE

Jun 25, 2020 in Python by Sirajul
• 59,230 points
5,371 views
0 votes
1 answer

What is the procedure to update spyder on Anaconda?

This is a pretty simple thing to ...READ MORE

Aug 19, 2019 in Python by Arvind
• 3,040 points
11,867 views
0 votes
1 answer

i write this python to read dataset into panda data frame but im getting NameError: name 'true' is not defined. Below is the code:

change  def parse(path):   g = gz ...READ MORE

Mar 15, 2020 in Python by Abhishek Shingadiya
3,237 views
0 votes
1 answer

How to set Colorbar Range in matplotlib using Python

You could scale your data to the ...READ MORE

Nov 22, 2018 in Python by Nymeria
• 3,560 points
23,532 views
0 votes
0 answers

Python error " TypeError: string indices must be integers "

I am trying to execute following code ...READ MORE

Apr 3, 2020 in Python by Falguni
• 140 points

edited Apr 5, 2020 by Falguni 2,023 views
0 votes
1 answer

How to remove a key from a Python dictionary?

Hello, If you need to remove a lot ...READ MORE

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

Python error "SyntaxError: invalid syntax"

but i m getting this ouput: Enter the ...READ MORE

Mar 20, 2020 in Python by anonymous
8,068 views
+1 vote
2 answers

How to print first character of each word in upper case of a string in Python

class Solution:     def firstAlphabet(self, s):             self.s=s              k=''              k=k+s[0]              for i in range(len(s)):                     if ...READ MORE

Oct 28, 2020 in Python by Anurag
11,780 views
0 votes
1 answer

ImportError: No module named toolkit.interface

I think you didn't set your python ...READ MORE

Apr 22, 2020 in Python by MD
• 95,440 points
993 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,906 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,555 views
0 votes
1 answer

How to connect mail server with smtplib module in python?

Hi@akhtar, You can connect mail server using smtplib ...READ MORE

Apr 15, 2020 in Python by MD
• 95,440 points
1,203 views
0 votes
0 answers

Numerical_vision_problem [distance_Pixels]

hello everybody, hoping that all with good ...READ MORE

May 2, 2020 in Python by anonymous
• 120 points
505 views
0 votes
0 answers

How to iterate through an S3 bucket to find the last modified file (and then save that to a local folder)

Hi there guys, I've been tasked with ...READ MORE

Feb 18, 2020 in Python by Markus
• 120 points
3,631 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,626 views
0 votes
1 answer

Building Time Series Model - Getting error involving datetime

Hey sharonda, Use a python datetime or string  results.get_prediction(start='2020-04-08', ...READ MORE

Apr 8, 2020 in Python by Niroj
• 82,880 points
1,332 views