Trending questions in Python

+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 312 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
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
370 views
0 votes
1 answer

Example code for creating broken barh graph using matplotlib

Try this, it should work well. import matplotlib.pyplot ...READ MORE

May 27, 2019 in Python by Himanshu
1,964 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
410 views
0 votes
1 answer

Reconstruct an array by replacing every element with a[[i-1]%K] - Python

Hey varsha, Have a look at this ...READ MORE

Jun 14, 2019 in Python by Miya
1,174 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
324 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
620 views
0 votes
1 answer

How to create blank csv file in pandas?

Try this code: open("User data.csv", 'w') Where User data.csv ...READ MORE

Apr 6, 2019 in Python by Will
4,139 views
0 votes
1 answer

mapping two numpy arrays

Here's a NumPythonic vectorized approach - B[:,1][(A == ...READ MORE

May 10, 2019 in Python by SDeb
• 13,300 points
2,637 views
0 votes
1 answer

Where is builtins module located?

The module is built-in to the python ...READ MORE

Jun 19, 2019 in Python by SDeb
• 13,300 points
893 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
496 views
0 votes
1 answer

Length and dimensions of NumPy arrays

The length of NumPy arrays can be ...READ MORE

Jun 14, 2019 in Python by Wajiha
• 1,950 points
1,074 views
0 votes
1 answer

Create an ec2 instance using boto

Hi @Neel, try this script: reservations = conn.get_all_instances(instance_ids=[sys.argv[1]]) instances ...READ MORE

Jun 24, 2019 in Python by Varsha
637 views
0 votes
1 answer

How to add new keys to an already created python dictionary?

my_dict = {'name':'Jack', 'age': 26} my_dict['address'] = 'Downtown' ...READ MORE

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

Python error "AttributeError: incompatible shape for a non-contiguous array"

It is not always possible to change ...READ MORE

May 29, 2019 in Python by Imran
1,738 views
0 votes
1 answer

Python code Tic Tac Toe game

You could use random.shuffle from random import shuffle players ...READ MORE

May 28, 2019 in Python by Idam
1,772 views
0 votes
1 answer

'f' strings in Python

They are also known as Literal String ...READ MORE

Jun 25, 2019 in Python by Fata
• 1,050 points
557 views
0 votes
1 answer

Deleting elements from numpy array

Use the following code: import numpy as np a=np.array([1,2,3,4]) b=np.delete(a,2) OUTPUT: array([1, ...READ MORE

Jun 24, 2019 in Python by Fata
• 1,050 points

edited Jun 25, 2019 by Kalgi 590 views
0 votes
1 answer

How do I create 3 X 4 array of random numbers between 0 and 100 using python?

Use numpy in the following manner: np.random.rand(3,4)*100 When you ...READ MORE

May 24, 2019 in Python by Radhika
1,927 views
0 votes
1 answer

Is there a way to store a huge dataset as a dataframe using Pandas?

This can be easliy done by using ...READ MORE

Jun 22, 2019 in Python by Taj
• 1,080 points
713 views
0 votes
1 answer

How to append a row to a Pandas dataframe?

You can use the append method provided by pandas ...READ MORE

May 9, 2019 in Python by Raj
2,552 views
0 votes
1 answer

How to count number of anchor tags got?

I had a similar requirement, this is ...READ MORE

Apr 2, 2019 in Python by Riya
4,142 views
0 votes
1 answer

How to calculate cosine similarity between two lists using Pythong?

You should try SciPy. It has a bunch ...READ MORE

Dec 18, 2018 in Python by charlie_brown
• 7,720 points
8,704 views
0 votes
1 answer

Bash alias --> Python 2.7 to Python 3.3

Some linux utilities depend on python2.x currently. ...READ MORE

May 9, 2019 in Python by SDeb
• 13,300 points
2,526 views
0 votes
1 answer

An example showing how to plot the coherence of two signals

This should work well: import numpy as np import ...READ MORE

May 27, 2019 in Python by anonymous

edited May 27, 2019 by Kalgi 1,733 views
0 votes
2 answers

Do-while loop in Python

A more pythonic way would be this: ``` while ...READ MORE

Jul 6, 2020 in Python by Composer3
1,154 views
0 votes
1 answer

How to convert string in Pandas Series to lower case?

Suppose you have the series stored in ...READ MORE

May 13, 2019 in Python by Raj
2,319 views
0 votes
1 answer

Python: Sort list of lists numerically

You can try and De-dupe it with ...READ MORE

May 20, 2019 in Python by SDeb
• 13,300 points
2,024 views
0 votes
1 answer

what are sockets?

Sockets are basically open and close gateways ...READ MORE

Jun 25, 2019 in Python by Fata
• 1,050 points
439 views
0 votes
1 answer

Snake head placed on the center - Python using turtle

You can use turtle's goto() function. This ...READ MORE

Jun 21, 2019 in Python by Greg
607 views
0 votes
2 answers

What is the difference between python lists and arrays?

Python arrays and lists have the same ...READ MORE

Jun 11, 2019 in Python by Nisa
• 1,090 points
1,100 views
0 votes
1 answer

Example of creating horizontal bar chart using matplotlib

Try this: import matplotlib.pyplot as plt import numpy as ...READ MORE

May 27, 2019 in Python by Vaishnavi
1,660 views
0 votes
1 answer

Create ESB Volume using python

You only have to use two simple ...READ MORE

Jun 24, 2019 in Python by Greg
439 views
0 votes
1 answer

Getting this error Error sqlite3.InterfaceError: Error binding parameter 0 - probably unsupported type

Found out that the problem was that ...READ MORE

Oct 1, 2018 in Python by Priyaj
• 58,090 points
11,935 views
0 votes
1 answer

Why are Python lambdas useful?

The main purpose of anonymous functions come ...READ MORE

Jun 19, 2019 in Python by Wajiha
• 1,950 points
649 views
0 votes
1 answer

How do I run a set of code for all the requests in Flask?

Hi, You can use dedicated hooks(decorators) called before ...READ MORE

Jun 21, 2019 in Python by Shabnam
• 930 points
588 views
0 votes
0 answers

How do you install Tkinter in python?

What is the basic function of Tkinter ...READ MORE

Jun 24, 2019 in Python by Waseem
• 4,540 points
460 views
0 votes
1 answer

Tkinter to android translation

Even for native purposes, most developers would ...READ MORE

May 22, 2019 in Python by SDeb
• 13,300 points
1,847 views
0 votes
1 answer

How do I read a file on only read only mode in python?

Hey @David! TRy something like this: campaign_data = ...READ MORE

Jun 20, 2019 in Python by Jason
577 views
0 votes
1 answer

How to get current time in Python?

Hi, You can use Datetime class. Input: import datetime datetime.datetime.now() Output: datetime.datetime(2019, 6, ...READ MORE

Jun 22, 2019 in Python by Taj
• 1,080 points
526 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,993 views
0 votes
1 answer

Python pygame error : Failed loading libpng.dylib: dlopen(libpng.dylib, 2): image not found

Try installing libpng You can do it with ...READ MORE

May 31, 2019 in Python by SDeb
• 13,300 points
1,444 views
0 votes
1 answer

Shallow copying vs Deep copying

If you have an object and you ...READ MORE

Jun 11, 2019 in Python by Kyraa
953 views
0 votes
1 answer

Python from Python: restricting functionality?

This doesn't seem like a good idea ...READ MORE

Jun 24, 2019 in Python by SDeb
• 13,300 points
404 views
0 votes
1 answer

How do I trim the leading or trailing zeros from a 1d array in python?

Hey @Akki, you can use the numpy ...READ MORE

May 29, 2019 in Python by Wakir
1,469 views
0 votes
1 answer

How to get size of a list?

Hi, You can use built-in function "len" to ...READ MORE

Jun 21, 2019 in Python by Shabnam
• 930 points
503 views
0 votes
1 answer

Enter a 1-10, each on a new line in a file - python

Try something like this: i=1 for i in range(10): ...READ MORE

Jun 20, 2019 in Python by Greg
503 views
0 votes
1 answer

What are the naming conventions for variables and data types in python?

There are certain rules that we have ...READ MORE

May 21, 2019 in Python by Mohammad
• 3,230 points
1,840 views
0 votes
1 answer

Python code to send an email message from 1 email id to another

Hi @Deb, try out the following code: import ...READ MORE

Jun 11, 2019 in Python by Picentra
876 views