Most viewed questions in Python

0 votes
0 answers

ValueError: not enough values to unpack (expected 2, got 0)

I want to load the NSL_KDD data ...READ MORE

May 9, 2020 in Python by arezoo
• 220 points

edited May 13, 2020 by Gitika 11,582 views
0 votes
1 answer

How to call Python script from bash with an agrument?

Hi, You need to call the same command ...READ MORE

Jun 25, 2019 in Python by Shabnam
• 930 points
11,535 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,520 views
0 votes
1 answer

How to create a user in Django?

Hello @kartik, The correct way to create a ...READ MORE

Aug 17, 2020 in Python by Niroj
• 82,880 points
11,508 views
0 votes
1 answer

Python vs Cpython

So what is CPython? CPython is the original ...READ MORE

Aug 29, 2018 in Python by Priyaj
• 58,090 points
11,504 views
0 votes
1 answer

How to return the current user with Django Rest Framework?

Hello @kartik, The best way is to use ...READ MORE

Jun 25, 2020 in Python by Niroj
• 82,880 points
11,475 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,437 views
0 votes
1 answer

ImportError: cannot import name 'six' from 'django.utils' (/path-to-project/project/niroj/lib/python3.7/site-packages/django/utils/init.py)

Hello @kartik, Upgrading the packages will resolve the ...READ MORE

Aug 5, 2020 in Python by Niroj
• 82,880 points
11,435 views
0 votes
1 answer

What is the difference between re.search and re.match?

The theoritical approach can be this way, re.match is ...READ MORE

Aug 10, 2018 in Python by Priyaj
• 58,090 points
11,427 views
+1 vote
1 answer

Not able to Import scikitplot package in my Jupyter Lab

To overcome this issue, you need to ...READ MORE

Feb 21, 2019 in Python by Yami
11,350 views
0 votes
1 answer

How do I find current module name in python?

A module can find out its own ...READ MORE

Jul 30, 2019 in Python by Simran
11,347 views
0 votes
1 answer

How can I convert JSON to CSV?

I am not sure this question is ...READ MORE

Oct 1, 2018 in Python by aryya
• 7,450 points
11,344 views
0 votes
1 answer

How do you get the logical xor of two variables in Python?

What i found is that you can use ...READ MORE

Aug 10, 2018 in Python by Priyaj
• 58,090 points
11,329 views
0 votes
1 answer

How can I have Multiple Models in a single django ModelForm?

Hello @kartik, You can just show both forms ...READ MORE

Aug 13, 2020 in Python by Niroj
• 82,880 points
11,305 views
0 votes
1 answer

What is the use of Tkinter,Flask and Django? What is the main use of them? Can any of them help me in freelancing?

Hey, all the tools that you have ...READ MORE

Feb 27, 2019 in Python by Priyaj
• 58,090 points
11,305 views
0 votes
1 answer

How to replace values with None in Pandas data frame in Python?

Actually in later versions of pandas this ...READ MORE

Aug 30, 2018 in Python by Priyaj
• 58,090 points
11,183 views
0 votes
2 answers

ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

R u getting the issue while running ...READ MORE

Nov 2, 2020 in Python by anonymous
11,053 views
0 votes
2 answers

How to create empty pandas dataframe?

To create a simple empty DataFrame, use ...READ MORE

Aug 10, 2020 in Python by Nehal
• 140 points

edited Aug 10, 2020 by Nehal 11,015 views
0 votes
3 answers

How to draw a tic tac toe board in python?

def printTable():             for i in range(1,10):                     print(" ",end=' ')                     if(i%3==0 ...READ MORE

Oct 11, 2020 in Python by Sumit Nagpal
10,997 views
0 votes
1 answer

How to get the latest file in a folder using python?

Hello @kartik,  would suggest using glob.iglob() instead of the glob.glob(), as ...READ MORE

May 27, 2020 in Python by Niroj
• 82,880 points
10,993 views
0 votes
1 answer

How to convert date string to date object in python?

Use this :-  >>> datetime.datetime.strptime('24052010', "%d%m%Y").date() datetime.date(2010, 5, 24) Hope ...READ MORE

Oct 22, 2018 in Python by Priyaj
• 58,090 points
10,988 views
0 votes
1 answer

Error while installing cv2 module in pycharm

Go to tools -> python console -> ...READ MORE

Jun 24, 2019 in Python by Quin
10,954 views
0 votes
1 answer

How to concatenate strings in django templates?

Hello @kartik, Don't use add for strings, you should define ...READ MORE

Aug 3, 2020 in Python by Niroj
• 82,880 points
10,793 views
0 votes
1 answer

How to convert CSV file to JSON file using Pandas?

Hi@akhtar, You can convert your CSV file to ...READ MORE

Jun 25, 2020 in Python by MD
• 95,440 points
10,790 views
0 votes
1 answer

How to return custom JSON in Django REST Framework?

Hello @kartik, There are 2 ways to custom ...READ MORE

Jun 25, 2020 in Python by Niroj
• 82,880 points
10,782 views
0 votes
1 answer

How do I check if input string is a valid regular expression or not in Python?

Hi. Good question! Well, just like what ...READ MORE

Feb 12, 2019 in Python by Nymeria
• 3,560 points
10,780 views
+1 vote
1 answer

Error:Unable to import path from django.urls

Hello @kartik, You need Django version 2 pip install ...READ MORE

Jul 2, 2020 in Python by Niroj
• 82,880 points
10,766 views
0 votes
1 answer

How to load Numpy array in Jupyter Notebook?

Hi@akhtar, You can use numpy.load() function to load ...READ MORE

Jun 22, 2020 in Python by MD
• 95,440 points
10,736 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
10,694 views
0 votes
1 answer

How do you get the logical xor of two variables in Python?

If you're already normalizing the inputs to ...READ MORE

May 29, 2018 in Python by aryya
• 7,450 points
10,463 views
0 votes
1 answer

Error:django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb

Hello @kartik, It looks like you don't have ...READ MORE

Jun 24, 2020 in Python by Niroj
• 82,880 points
10,415 views
0 votes
1 answer

reverse a list without built-in functions

You can do it in 2 ways: Using ...READ MORE

Jul 31, 2019 in Python by Wajiha
• 1,950 points
10,369 views
0 votes
1 answer

What is `related_name` used for in Django?

Hello @kartik, The related_name attribute specifies the name of the ...READ MORE

Jun 26, 2020 in Python by Niroj
• 82,880 points
10,364 views
0 votes
1 answer

What is the purpose of ​#!/usr/bin/python​on the first line in the above code?

Hey, @Roshni, By specifying #!/usr/bin/python you specify exactly ...READ MORE

Jun 23, 2020 in Python by Gitika
• 65,910 points
10,362 views
0 votes
1 answer

How to print just one column in pandas?

You can use the header to print ...READ MORE

Apr 4, 2019 in Python by TIna
10,343 views
0 votes
1 answer

How to run a Function in Spyder and check output?

You will see the output of the ...READ MORE

May 17, 2019 in Python by Omkar
• 69,210 points
10,267 views
0 votes
1 answer

How can I parse a YAML file in Python?

Read & Write YAML files with Python ...READ MORE

Nov 21, 2018 in Python by Nymeria
• 3,560 points
10,267 views
0 votes
1 answer

How to disable a method in a ViewSet, django-rest-framework

Hello @kartik, You could keep using viewsets.ModelViewSet and define http_method_names on your ...READ MORE

Jun 26, 2020 in Python by Niroj
• 82,880 points
10,190 views
0 votes
1 answer

How can I get the username of the logged-in user in Django?

Hello @kartik, You can use the request object ...READ MORE

Jul 29, 2020 in Python by Niroj
• 82,880 points
10,180 views
+1 vote
2 answers

Measuring the distance between pixels on OpenCv with Python

You can try this: Mat pts1(nPts, 1, CV_8UC2), ...READ MORE

Aug 24, 2018 in Python by Omkar
• 69,210 points
10,150 views
0 votes
1 answer

sys.argv[1] what is the meaning of it?

sys.argv[1] contains the first command line argument passed to your script. For ...READ MORE

Dec 18, 2018 in Python by abc
10,146 views
0 votes
1 answer

Got an error while installing opencv-python

Hello @Nishant, The error you got itself suggest ...READ MORE

Sep 17, 2020 in Python by Niroj
• 82,880 points
10,103 views
0 votes
1 answer

How to look up a dictionary value with a variable in Django template?

Hii @kartik, Write a custom template filter: from django.template.defaulttags ...READ MORE

Aug 3, 2020 in Python by Niroj
• 82,880 points
10,096 views
+1 vote
1 answer

Python error "pygame.error: Couldn't open pygame.png"

icon = pygame.image.load('spaceship.png') pygame.error: Couldn't open spaceship.png I am ...READ MORE

Apr 9, 2020 in Python by Ali
10,088 views
+1 vote
1 answer

Error loading package list:pypi.python.org

You can try doing the following : go ...READ MORE

Jan 9, 2019 in Python by ana1504.k
• 7,910 points
10,038 views
0 votes
1 answer

How to sort Counter by value using python?

Use the Counter.most_common() method, it'll sort the items for you: >>> ...READ MORE

May 23, 2018 in Python by charlie_brown
• 7,720 points
10,006 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
9,981 views
0 votes
1 answer

How do I add a link from the Django admin page of one object to the admin page of a related object?

Hello @kartik, Set show_change_link to True (False by default) in your inline ...READ MORE

Jun 12, 2020 in Python by Niroj
• 82,880 points
9,938 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
9,918 views
0 votes
1 answer

ValueError: could not broadcast input array from shape (4,1) into shape (4)

Hey @Giorgio, You can try this hope this ...READ MORE

Feb 18, 2020 in Python by Gitika
• 65,910 points
9,909 views