Python
Appending a list or series to a pandas DataFrame as a row?
So I have initialized an empty pandas DataFrame and I would like to iteratively append lists (or Series) as rows in this DataFrame. What is the best way of doing this?
How to add a location filter to tweepy module
I have found the following piece of code that works pretty well for letting me view in Python Shell the standard 1% of the twitter firehose:
How to use re to find consecutive, repeated chars
I want to find all consecutive, repeated character blocks in a string. For example, consider the following:
How to get instance variables in Python?
Is there a built-in method in Python to get an array of all a class’ instance variables? For example, if I have this code:
Matplotlib tight_layout() doesn’t take into account figure suptitle
If I add a subtitle to my matplotlib figure it gets overlaid by the subplot’s titles. Does anybody know how to easily take care of that? I tried the tight_layout() function, but it only makes things worse.
Difference between Python’s collections.Counter and nltk.probability.FreqDist
I want to calculate the term-frequencies of words in a text corpus. I’ve been using NLTK’s word_tokenize followed by probability.FreqDist for some time to get this done. The word_tokenize returns a list, which is converted to a frequency distribution by FreqDist. However, I recently came across the Counter function in collections (collections.Counter), which seems to be doing the exact same thing. Both FreqDist and Counter have a most_common(n) function which return the n most common words. Does anyone know if there’s a difference between these two? Is one faster than the other? Are there cases where one would work and the other wouldn’t?
How can you get the call tree with Python profilers?
I used to use a nice Apple profiler that is built into the System Monitor application. As long as your C++ code was compiled with debug information, you could sample your running application and it would print out an indented tree telling you what percent of the parent function’s time was spent in this function (and the body vs. other function calls).
How do I fix TypeError: ‘int’ object is not iterable?
I am trying to write a program that allows you to enter the number of students in a class, and then enter 3 test grades for each student to calculate averages. I am new to programing and I keep getting an error that I don’t understand what it means or how to fix it. This is what I have so far:
Creating cx_Freeze exe with Numpy for Python
Im trying to create a basic exe using cx_Freeze. It works for .py programs that don’t have numpy but I can’t get one made correctly with numpy.