Most answered questions in Python

0 votes
1 answer

How to approach the problem of finding the nearest square?

The following method should solve this.  def nearest_square(limit): ...READ MORE

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

Python table gives NaN when initialized with series

The NaN value you are getting is ...READ MORE

Jul 9, 2019 in Python by Yogi
1,157 views
0 votes
1 answer

yield keyword in Python

The yield keyword is used along with ...READ MORE

Jul 9, 2019 in Python by Wajiha
• 1,950 points
536 views
0 votes
1 answer

time.sleep() in Python

Sleep function plays a very important role ...READ MORE

Jul 9, 2019 in Python by Wajiha
• 1,950 points
363 views
0 votes
1 answer

What is list comprehension?

List comprehensions are used for creating new list from another ...READ MORE

Aug 2, 2019 in Python by Mohammad
• 3,230 points
1,017 views
0 votes
1 answer

How do you break out of a while loop in python?

Usually the execution moves out of the ...READ MORE

Aug 2, 2019 in Python by Mohammad
• 3,230 points
696 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,336 views
0 votes
1 answer

Splitting a column with multiple values in python

Try using the following: df['id'] = df.index+1 df.set_index('id').col_name.str.split(',', expand ...READ MORE

Jul 9, 2019 in Python by SDeb
• 13,300 points
3,106 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,115 views
0 votes
1 answer

Create a circle turtle - Python

Hey its pretty simple. Try this out: food ...READ MORE

Jul 8, 2019 in Python by Manasa
781 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
3,821 views
0 votes
1 answer

How do I make one turtle follow another turtle in python?

Try something like this: from turtle import Turtle, ...READ MORE

Jul 8, 2019 in Python by Ayushi
4,801 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,040 points
6,456 views
0 votes
1 answer

What is the difference between str() and repr() functions in Python?

str() is mostly used to create output ...READ MORE

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

How do you write a loop in python with conditional statements in python?

Lets say we have a problem statement ...READ MORE

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

convert a SAS datetime in Pandas

SAS date value is a value that ...READ MORE

Jul 8, 2019 in Python by SDeb
• 13,300 points
2,889 views
0 votes
1 answer

How to get the multiplication table of any number using list comprehension?

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

Jul 8, 2019 in Python by Sakshi
6,168 views
0 votes
1 answer

draw polygon based on user input - turtle python

Try something like this: import turtle # create a ...READ MORE

Jul 6, 2019 in Python by Umer
9,027 views
0 votes
1 answer

How do I draw a semi-circle only using turtle - Python

Try this: import turtle turtle = turtle.Pen() turtle.left(90) for x in ...READ MORE

Jul 6, 2019 in Python by Bheem
9,546 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
7,499 views
0 votes
1 answer

python - get the root from tkinter for turtle

Hey @Haseeb, try something like this: import turtle canvas ...READ MORE

Jul 6, 2019 in Python by Barbara
724 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,088 views
0 votes
1 answer

Move turtle using the arrow keys in Python

You can use something like this: wn.onkey(move_up, 'Up') wn.onkey(move_left, ...READ MORE

Jul 6, 2019 in Python by Travis
2,988 views
0 votes
1 answer

Python error "IndexError: Cannot choose from an empty sequence"

Hi @Isha, According to your error  File ...READ MORE

Jul 5, 2019 in Python by Patric
5,273 views
0 votes
1 answer

Python error "TypeError: string indices must be integers, not str"

Hey @Dipti email_s.append(email_1["email_address"]) This is the list on ...READ MORE

Jul 5, 2019 in Python by Jinu
22,714 views
0 votes
1 answer

How to install biopython module in python?

To install biopython on your project, simply ...READ MORE

Jul 8, 2019 in Python by Mohammad
• 3,230 points
1,445 views
0 votes
1 answer

Purpose of fit method in sklearn module in python?

it basically trains your model using the ...READ MORE

May 14, 2020 in Python by Mahesh
• 140 points
3,204 views
0 votes
1 answer

Which is a good python ide for android devices?

I will suggest you to go for ...READ MORE

Jul 5, 2019 in Python by Neel
• 3,020 points
2,693 views
0 votes
1 answer

How to install and use myql connector in Python?

You can use pip to search if ...READ MORE

Jul 5, 2019 in Python by Neel
• 3,020 points
1,298 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,780 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,380 views
0 votes
1 answer

Selecting Pandas Columns by dtype

You can use the following: df.loc[:, df.dtypes == ...READ MORE

Jul 5, 2019 in Python by SDeb
• 13,300 points
1,131 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,750 views
+1 vote
1 answer

How to modify list while iterating?

Hi, You can try slice operator mylist[::3] to skip across to ...READ MORE

Jul 5, 2019 in Python by Taj
• 1,080 points
653 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
4,472 views
0 votes
1 answer

How do I make a delay in Python?

Hahah! Yes, you need to create a ...READ MORE

Jul 4, 2019 in Python by Pooja
1,050 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,734 views
0 votes
1 answer

Python application from .py to .exe

You can use pyinstaller for this purpose. PyInstaller bundles ...READ MORE

Jul 4, 2019 in Python by Pooja
457 views
+1 vote
1 answer

Add Variables to Tuple

Use the following piece of code: ...READ MORE

Jul 4, 2019 in Python by Wajiha
• 1,950 points

edited Jul 5, 2019 by Kalgi 318 views
+1 vote
1 answer

Creating a range of dates in Python

Yes, you can do it as follows: import ...READ MORE

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

Python error "AttributeError: 'str' object has no attribute 'casefold'"

Check your python version. Casefold is possible ...READ MORE

Jul 4, 2019 in Python by Yesha
5,838 views
0 votes
1 answer

Is there a list of timezones in python?

import pytz list(pytz.common_timezones) READ MORE

Aug 2, 2019 in Python by Mohammad
• 3,230 points
971 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

pandas and Stata 13 files

You can check with the following: Update your ...READ MORE

Jul 4, 2019 in Python by SDeb
• 13,300 points
573 views
+1 vote
1 answer

How to install scipy for Python 2.7?

Open the command prompt and follow these ...READ MORE

Jul 4, 2019 in Python by Arvind
• 3,040 points
2,461 views
0 votes
1 answer

How to access the elements of a dictionary using index ?

Suppose you have a dictionary num = ...READ MORE

Jul 4, 2019 in Python by Arvind
• 3,040 points
2,051 views
+1 vote
1 answer

Error in git and python command

The answer to your first problem is ...READ MORE

Jul 4, 2019 in Python by Simran
863 views
0 votes
1 answer

How to create a train and test sample from one dataframe using pandas?

Hi, The below written code can help you ...READ MORE

Jul 4, 2019 in Python by Taj
• 1,080 points
5,533 views
0 votes
1 answer

How do I loop backward using indices in Python?

Hi, You can make use of negative indices ...READ MORE

Jul 4, 2019 in Python by Taj
• 1,080 points
425 views