I’ve written a function below that takes, as arguments, a dataframe (df) and two of its column names (var1, var2). Then it creates interaction variables for the two variables and adds those columns to the original dataframe. The code works when I hard code it, but when I try to call the function like: I receive no errors but the
Python – requests.exceptions.SSLError – dh key too small
I’m scraping some internal pages using Python and requests. I’ve turned off SSL verifications and warnings. On certain servers I receive an SSL error I can’t get past. This happens both in/out of Cygwin, in Windows and OSX. My research hinted at outdated OpenSSL on the server. I’m looking for a fix client side ideally. Edit: I was able to
How to create a numpy array from a pydub AudioSegment?
I’m aware of the following question: How to create a pydub AudioSegment using an numpy array? My question is the right opposite. If I have a pydub AudioSegment how can I convert it to a numpy array? I would like to use scipy filters and so on. It is not very clear to me what is the internal structure of
Python StatsModels Time Series Decomposition Duplicate Plot
I am using a mixture of Pandas and StatsModels to plot a time series decomposition. I followed this answer but when I call plot() it seems to be plotting a duplicate. My DataFrame looks like My index looks like but when I plot the decomposition I get this Strangely, if I plot only an element of the decomposition, the duplication
Accessing Revit API from outside Revit
I’ve used RevitPythonShell and Dynamo, but would like to use my existing Python IDE (Eclipse) where I have my configuration for logging, debugging, GitHub integration, etc. I’m comfortable with transactions and the overall API, and I’ve invested some time in reading about the Revit API and modeless connections, and others asking similar questions. Some of them are a few years
Save Matplotlib figure as TIFF
Does anyone know how to save a Matplotlib figure as *.tiff? It seems that this format is not supported in Python, while the journals are quite often ask for that format. I am adding some minimal code: This works: But this does not: Answer This is great! Thanks ot Martin Evans. However, for those who would like to make it
Matplotlib can’t find font installed in my Linux machine
I am trying to draw an xkcd-style plot with matplotlib (ver. 1.4.2) under Python 3. When I try to run: It opens an empty window without any image and I get the error: I have Humor Sans installed. I checked it with fc-list | grep Humor. It can also be used within other programs, like Libre Office. I also have
How do I merge two django db’s?
I have two instances of the same Django app. I need to merge the data in these DBs to one DB. I considered Natural Key fixtures, but I have many objects whose natural key involves fields from a related model, so they are not being serialized when I am serializing using natural keys. For example This account’s fixture: (notice it
How to create a tuple of an empty tuple in Python?
How can I create a tuple consisting of just an empty tuple, i.e. (())? I have tried tuple(tuple()), tuple(tuple(tuple())), tuple([]) and tuple(tuple([])) which all gave me (). The reason that I use such a thing is as follows: Assume you have n bags with m items. To represent a list of items in a bag, I use a tuple of
Artificially creating memory usage in Python
I’m trying to create a pure memory intensive script in Python for testing purposes but every script that I try also increases my cpu. I’ve read this post and I also tried, among others: in order to copy an array to another array but once again I had cpu variations as well. UPDATED So, how can I cause a standard