How to remove all the punctuation in a string? (Python)

A really simple implementation is: and keep adding any other types of punctuation. A more efficient way would be Edit: There is some more discussion on efficiency and other implementations here: Best way to strip punctuation from a string in Python

What is the maximum recursion depth in Python, and how to increase it?

It is a guard against a stack overflow, yes. Python (or rather, the CPython implementation) doesn’t optimize tail recursion, and unbridled recursion causes stack overflows. You can check the recursion limit with sys.getrecursionlimit: and change the recursion limit with sys.setrecursionlimit: but doing so is dangerous — the standard limit is a little conservative, but Python stackframes can … Read more

Why do I get: “Length of values does not match length of index” error?

My best guess relies in this part: It first says that myTempData[‘Actuals’] is a column of size len(MyActualData.index) containing only True values. Next, it replaces everything by another column of size len(MyExpectedData.index) (which I expect to be different) containing False values. You can first create a column of True values and, only then, replace False ones:

Python group by

Do it in 2 steps. First, create a dictionary. Then, convert that dictionary into the expected format. It is also possible with itertools.groupby but it requires the input to be sorted first. Note both of these do not respect the original order of the keys. You need an OrderedDict if you need to keep the … Read more

Rename Pandas DataFrame Index

The rename method takes a dictionary for the index which applies to index values.You want to rename to index level’s name: A good way to think about this is that columns and index are the same type of object (Index or MultiIndex), and you can interchange the two via transpose. This is a little bit confusing since the index names … Read more

Remove list from list in Python

Possible Duplicate:Get difference from two lists in Python What is a simplified way of doing this? I have been trying on my own, and I can’t figure it out. list a and list b, the new list should have items that are only in list a. So: I tried writing code, but every time it … Read more

How to draw a circle in PyGame?

Hi I am having a problem with drawing a circle ERROR: module object has no attribute ‘circle’. what am I doing wrong? And also how can I put numbers in circles? For example: (first click is circle with 0 second is circle with 1 and so on)