Quantcast
Channel: User Roger Fan - Stack Overflow
Browsing all 42 articles
Browse latest View live

Comment by Roger Fan on Python: free memory after modifying list of large...

There's no need to do any replacing. Creating the new list won't copy any memory. Think of the variable as a label, the label will exist in both lists but both labels will be pointing to the same object.

View Article



Comment by Roger Fan on Python: free memory after modifying list of large...

@mgilson If you need that fine-tuned control of memory then garbage-collected languages are probably not for you.

View Article

Comment by Roger Fan on Would any CPython 2.7 code work in Jython 2.7b3?

Anything written in pure python should work in Jython. But anything third-party packages with C code will almost certainly not. If lxml has C code, which it seems that it does, then it will probably...

View Article

Comment by Roger Fan on How to make pip install python 2.x modules in python 3.x

@whiletrue For open-source packages, the other option is to contribute. If you feel that you're capable, do the community a service and port it over.

View Article

Comment by Roger Fan on Determining the physical height of a gaussian curve...

Normal pdfs are greatest at their mean. So you can use height*scipy.stats.norm.pdf(0, scale=width) to get the maximum value.

View Article


Comment by Roger Fan on Why do python sets hold False and Zero exclusively?

Related question: stackoverflow.com/questions/2764017/….

View Article

Comment by Roger Fan on Click Events in visual studio

There isn't really a question here, is there?

View Article

Comment by Roger Fan on R - Time series data with ggplot2

"Wonky" is not a helpful descriptor. It would be helpful to provide a (small) example of the data that is causing the behavior.

View Article


Comment by Roger Fan on Python: import multiple modules AS

You could write another module that simply imports all of those functions into its namespace in __init__.py. Then just import your new module.

View Article


Comment by Roger Fan on Extract values by key from a nested dictionary

If you've made attempts at the problem, you should include what you've tried and the specific problems (including exceptions and/or full stacktraces) that you are having.

View Article

Comment by Roger Fan on Plotting with a For loop in Matlab

You should include the code that you have (preferably as a minimal example). It can help clarify your intent and any issues you're having.

View Article

Comment by Roger Fan on numpy.polyfit gives empty residuals array

Can you give a small example of some data that causes this behavior?

View Article

Comment by Roger Fan on Python string get leading characters up to first comma

@Menegazzo True. I added a line to convert it to a list of floats.

View Article


Answer by Roger Fan for Numpy nanmean and dataframe (possible bug?)

It's definitely strange behavior. I don't have the answers, but it mostly seems that entire pandas DataFrames can be elements of numpy arrays, which results in strange behavior. I'm guessing this...

View Article

Answer by Roger Fan for Changes of clustering results after each time run in...

When using k-means, you want to set the random_state parameter in KMeans (see the documentation). Set this to either an int or a RandomState instance. km = KMeans(n_clusters=number_of_k,...

View Article


Answer by Roger Fan for Is there intention to build a read_sas7bdat()...

This is the github issue related to adding sas import functions. If you scroll to the end you can see that it's a continuing conversation. To summarize the last couple posts, there are no near-term...

View Article

Answer by Roger Fan for Alternative to string.strip

split is a method of strings now. map is easily replaced with list or generator comprehensions.print([i.strip() for i in s])

View Article


Answer by Roger Fan for Finding closest three x,y points in three arrays

Let's try timing some different solutions to see.I'm going to initialize three arrays using numpy's random functions. If you have existing variables that are lists of tuples or lists of lists, just...

View Article

Answer by Roger Fan for Indexing vs Reverse-indexing

Note that, independent of any performance considerations, it's pretty clear that list1[-1] is the proper way to do it. It's concise, easy-to-read, and directly expresses your intent.That said, here are...

View Article

Answer by Roger Fan for How do I call a function with arbitrary parameters...

You're close, all you need to do is add a * in front of the tuple (or ** in front of a dict for keyword arguments) when calling the interior function. This is called argument unpacking.def wrapper(fn,...

View Article
Browsing all 42 articles
Browse latest View live




Latest Images