Quantcast
Channel: User MorganM - Stack Overflow
Browsing all 14 articles
Browse latest View live

Comment by MorganM on dataframe boolean selection along columns instead of row

Yes, that is precisely what I was looking for.

View Article



Comment by MorganM on how to select multiple values from a single level of a...

Thanks, I wasn't aware of slice. After looking over the docs, it seems like this will also work: df.loc[:, (slice(None), ['j', 'k'])]

View Article

Comment by MorganM on merging an empty pandas Series with inner join does not...

I have also tested to see if this holds true for a non-integer index or column names. Neither seems to affect this result. In case it matters, I'm on pandas 0.14.1

View Article

Comment by MorganM on Elegant way to mask out intervals between events...

Yes, that is correct

View Article

Comment by MorganM on Elegant way to mask out intervals between events...

I love the logic of this one, but I'm clocking it at ~2x slower than @nneonneo 's answer. Thanks for introducing me to reduceat, though! Another hidden gem in numpy.

View Article


Comment by MorganM on Why is pandas transform on multiple columns slower than...

I was using 0.18, but just upgraded to 0.20 and now get the same results as you. All at once is now faster. Thanks to whoever fixed this in the last two releases!

View Article

Answer by MorganM for Google cloud compute not recognizing any resources

Turns out I was doing all of my references to the project by name rather than ID. If you set a project by project name, it won't error, but it also won't actually give you access to any of that...

View Article

how to specify a custom compression filter in h5py

According to they h5py documentation, "compression filters can be dynamically loaded by the underlying HDF5 library. This is done by passing a filter number to Group.create_dataset() as the compression...

View Article


unexpected poor performance of GMM from sklearn

I'm trying to model some simulated data using the DPGMM classifier from scikitlearn, but I'm getting poor performance. Here is the example I'm using:from sklearn import mixtureimport numpy as npimport...

View Article


filter numpy array with row-specific criteria

Suppose I have a 2d numpy array and I want to filter for the elements that pass a certain criterion on a per-row basis. For example, I want only the elements that are above the 90th percentile for...

View Article

how to select multiple values from a single level of a dataframe multiindex

If I have the following:df = pd.DataFrame(np.random.random((4,8)))tupleList = zip([x for x in 'abcdefgh'], [y for y in ['iijjkkll'])ind = pd.MultiIndex.from_tuples(tupleList)df.columns = indIn [71]:...

View Article

Google cloud compute not recognizing any resources

I've been playing around with the google cloud compute platform and everything was fine until all of a sudden last night it seemed unable to recognize any resources. Whenever I try to do anything, for...

View Article

Answer by MorganM for Iterate over rows and expand pandas dataframe

Not as much interesting/fancy pandas usage, but this works:import numpy as npdfIn.loc[:, 'location'] = dfIn.location.apply(np.atleast_1d)all_locations = np.hstack(dfIn.location)all_names =...

View Article


dataframe boolean selection along columns instead of row

Suppose I have the following dataframe: a b c d 0 0.049531 0.408824 0.975756 0.6583471 0.981644 0.520834 0.258911 0.6396642 0.641042 0.534873 0.806442 0.0666253 0.764057 0.063252 0.256748 0.045850and I...

View Article
Browsing all 14 articles
Browse latest View live


Latest Images