Latest questions in Python

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,772 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,357 views
0 votes
3 answers

Pandas - FillNa with another column

You could do df.Cat1 = np.where(df.Cat1.isnull(), df.Cat2, df.Cat1 ...READ MORE

Dec 15, 2020 in Python by Roshni
• 10,520 points
84,124 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,116 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,733 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
636 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,445 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,038 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,711 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
432 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 314 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,261 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,810 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
936 views
0 votes
0 answers

What is the use of cursor while querying a sqlite database?

I am completely new to sqlite, and ...READ MORE

Jul 4, 2019 in Python by Waseem
• 4,540 points
326 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,812 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
558 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,432 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,023 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
834 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,519 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
411 views
0 votes
1 answer

Can't use read() for html2text?

decode() the content with the charset sent inside ...READ MORE

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

Populate QComboBox with a list

It looks like you're using the old ...READ MORE

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

What is the purpose of hash function in python?

The hash() method returns the hash value of an object if it ...READ MORE

Aug 2, 2019 in Python by Mohammad
• 3,230 points
701 views
+1 vote
4 answers

How do i resolve the "unexpected indent" error in python?

Look for the whitespaces which are not ...READ MORE

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

Why is Seaborn better than Mtaplotlib?

Factually, Matplotlib is good but Seaborn is ...READ MORE

Jul 3, 2019 in Python by Wajiha
• 1,950 points
371 views
0 votes
1 answer

How to check if a given string matches a particular pattern in Python?

You can use re module of python ...READ MORE

Jul 3, 2019 in Python by Neel
• 3,020 points
994 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,950 points
3,952 views
0 votes
1 answer

Is it possible to print all the modules imported in a python script?

Since I am using Python 3.6, I ...READ MORE

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

How to change tuple's existing elements?

Hi Priyankar, I understand your problem, but Tuple is immutable - ...READ MORE

Jul 2, 2019 in Python by sampriti
• 1,120 points
2,551 views
0 votes
4 answers

Is it possible to call one python script from another Python Script?

Try using os.system: os.system("script2.py 1") execfile is different because it is ...READ MORE

Dec 16, 2020 in Python by Gitika
• 65,910 points
68,670 views
0 votes
1 answer

How to find exponent of a number in Python?

Yes you can do it using the ...READ MORE

Jul 2, 2019 in Python by Arvind
• 3,040 points
2,071 views
0 votes
2 answers

How do you convert a dictionary to a defaultdict?

from collections import defaultdict a = {1: 2, ...READ MORE

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

How do i install numpy on windows?

Python Package Index (PyPI) is a repository ...READ MORE

Jul 3, 2019 in Python by anonymous
502 views
0 votes
1 answer

Why do variables have bigger scopes in Python than in C?

Only functions, modules, and the bodies of ...READ MORE

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

Slicing a list using a variable, in Python

Yes its possible. Use the following piece ...READ MORE

Jul 2, 2019 in Python by Wajiha
• 1,950 points
1,715 views
0 votes
1 answer

What does the operator "/=" do in python?

x = 20 res = x /= 5 print(res) The ...READ MORE

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

What are raw string literals?

A raw string literal opens with a sequence of ...READ MORE

Jul 31, 2019 in Python by Mohammad
• 3,230 points
644 views
+1 vote
1 answer

Converting integers to strings

Yes you can convert integers to strings ...READ MORE

Jul 1, 2019 in Python by Nisa
• 1,090 points
412 views
+1 vote
1 answer

How is set() implemented?

Sets in Python can be created using ...READ MORE

Jul 1, 2019 in Python by anonymous
430 views
0 votes
2 answers

Get key by value in dictionary

I have slightly modified your program to ...READ MORE

Nov 25, 2021 in Python by Python Coder
598 views
0 votes
1 answer

How to read a large file, line by line, in Python?

The correct, fully Pythonic way to read ...READ MORE

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

Python urllib2 Response header

Try to request as Firefox does. You ...READ MORE

Jun 28, 2019 in Python by SDeb
• 13,300 points
2,068 views
0 votes
1 answer

Access the sole element of a set

Use set.pop: >>> {1}.pop() 1 >>> In your case, it would be: return ...READ MORE

Jun 28, 2019 in Python by SDeb
• 13,300 points
498 views
+1 vote
1 answer

is it possible to compare a values to a backslash in Python?

The backslash "\" character is used to ...READ MORE

Jun 28, 2019 in Python by Neel
• 3,020 points
1,462 views
0 votes
1 answer

how to use urllib module in python?

If you are using Python 3.x then ...READ MORE

Jun 28, 2019 in Python by Neel
• 3,020 points
614 views
0 votes
0 answers

How to remove elements from a list that may or may not be present?

In case I want to remove some ...READ MORE

Jun 27, 2019 in Python by Nisa
• 1,090 points
624 views
0 votes
4 answers

how to sort a list of numbers without using built-in functions like min, max or any other function?

Yes it is possible. You can refer ...READ MORE

Jun 27, 2019 in Python by Arvind
• 3,040 points
184,844 views