Quantcast
Channel: User chrisaycock - Stack Overflow
Browsing all 38 articles
Browse latest View live

Comment by chrisaycock on trying to building on OSX but got "No rule to make...

I want to see if this is purely an ANTLR build issue. (The reason you don't need to install ANTLR is that it is built for you automatically.) Can you try the following? cd thirdparty/antlr/; unzip...

View Article



Comment by chrisaycock on trying to building on OSX but got "No rule to make...

@TyLiu You can "accept" this answer by clicking the green check mark. That will indicate that your question has been resolved.

View Article

Comment by chrisaycock on Shift elements in a numpy array

The fastest method is the pre-allocation that I posted at the end of my question. Your Series technique took 146 us on my computer, whereas my approach took under 4 us.

View Article

Comment by chrisaycock on Pandas: Shift down values by one row within a group

@GammaCat I have reverted your revision. You are entitled to post your own answer. Do not change the code in an existing answer; edits are for formatting and typographical errors, not code changes.

View Article

Comment by chrisaycock on How can I get to know the IP address for interfaces...

@Lanzelot I have updated my answer with Luiz Normando's patch.

View Article


Comment by chrisaycock on Shift elements in a numpy array

This is neither clean nor fast.

View Article

Comment by chrisaycock on How to save all embedded images of local html file...

Assuming your encoding is data:image/png;base64, you'd extract the "text" from each embedded image and save separately as .txt files. Then run certutil -decode img.txt img.png.

View Article

Comment by chrisaycock on Explicit specialization in non-namespace scope

Removing the template<> worked for me as well.

View Article


Comment by chrisaycock on Shift elements in a numpy array

I answered my own question. See the last version that pre-allocates the array. Also, np.roll is already suggested in this answer.

View Article


Comment by chrisaycock on Shift elements in a numpy array

There is a fatal error in your code. Your benchmark_shift7() calls shift6() when it is supposed to call shift7(). Correcting this shows that using a deque by far the slowest operation. Also, your...

View Article

Comment by chrisaycock on In Pandas, how can I replace a subset of the...

Every third row would imply multiple rows. I.e., you could have more rows on the right-hand side of the assignment than on the left-hand side.

View Article

Comment by chrisaycock on Excel DocEvent stops working following TCP messaging

@JeremyThompson This is on Windows 10 Pro.

View Article

Answer by chrisaycock for Converting string to list in python

JSON expects strings to be wrapped with double quotes; the single quotes in your example are causing the issue. If you know that you can just replace single with double, then you can do this:In [26]:...

View Article


Answer by chrisaycock for How can I add an unlimited set of integers in...

Instead of printing in a loop like you've done, just join the inputs (and be sure to convert to str first).In [11]: myList = [1, 2, 3]In [12]: print('+'.join(map(str, myList)))1 + 2 + 3

View Article

Answer by chrisaycock for How to use 2 argument on the Lambda function with...

I would call .apply() with axis=1 to operate on rows. And then pass each item from the Series to the function directly.data['Location'] = np.where(data['Market'] == 'P', 'Local',...

View Article


Answer by chrisaycock for Substract value from dataframe under certain...

Some preliminary assignments:max_charge = 11to_add = np.zeros(len(df.columns), dtype=np.int64)maxs = to_add + max_chargeresult = []Perform forward adjustments to each row:for r in df.values: row = r +...

View Article

Answer by chrisaycock for How to get statistics of group size after groupby?

df['Group'] = np.where(df['ID'].isin([1, 2]), 'A', 'B')df2 = df.groupby(['Group','ID']).size()df2.groupby('Group').agg(['mean', 'min', 'max'])Here's what I got: mean min maxGroup A 2.5 2 3B 3.0 1 5

View Article


Answer by chrisaycock for Grouping column values together

In [8]: df.groupby(np.where(df['Class'].isin([1, 2, 3]), 'P', 'E'))[['price', 'demand']].agg(['sum', 'mean'])Out[8]: price demand sum mean sum meanE 87 43.5 45 22.5P 186 46.5 38 9.5

View Article

Answer by chrisaycock for How to get the number of CPUs in Linux using C?

#include <unistd.h>long number_of_processors = sysconf(_SC_NPROCESSORS_ONLN);

View Article

Answer by chrisaycock for Create man pages for my own C library

Those comments you see are probably doxygen markup. That can produce man, HTML, and a variety of other formats.

View Article
Browsing all 38 articles
Browse latest View live




Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>
<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596344.js" async> </script>