filtering
Pandas equivalent of GROUP BY HAVING in SQL
As mentioned in unutbu’s comment, groupby’s filter is the equivalent of SQL’S HAVING: In [11]: df = pd.DataFrame([[1, 2], [1, 3], [5, 6]], columns=[‘A’, ‘B’]) In [12]: df Out[12]: A B 0 1 2 1 1 3 2 5 6 In [13]: g = df.groupby(‘A’) # GROUP BY A In [14]: g.filter(lambda x: len(x) > … Read more
Filtering multiple items in a multi-index Pandas dataframe
You can get_level_values in conjunction with Boolean slicing. In [50]: print df[np.in1d(df.index.get_level_values(1), [‘Lake’, ‘River’, ‘Upland’])] Area NSRCODE PBL_AWI CM Lake 57124.819333 River 1603.906642 LBH Lake 258046.508310 River 44262.807900 The same idea can be expressed in many different ways, such as df[df.index.get_level_values(‘PBL_AWI’).isin([‘Lake’, ‘River’, ‘Upland’])] Note that you have ‘upland’ in your data instead of ‘Upland’
Gaussian filter in MATLAB
You first create the filter with fspecial and then convolve the image with the filter using imfilter (which works on multidimensional images as in the example). You specify sigma and hsize in fspecial. Code: %%# Read an image I = imread(‘peppers.png’); %# Create the gaussian filter with hsize = [5 5] and sigma = 2 … Read more
How to profile for one table in SQL Server?
You can’t set filter to trace specific table directly. What you can do is specify a filter for Text Data: File -> Properties -> Event Selection -> Column Filters -> TextData -> Like -> [Table Name] You may find it important to wrap your table’s name with wildcard characters: “%table name%”.
LINQ Where Ignore Accentuation and Case
To ignore case and accents (diacritics) you can first define an extension method like this: public static string RemoveDiacritics(this String s) { String normalizedString = s.Normalize(NormalizationForm.FormD); StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < normalizedString.Length; i++) { Char c = normalizedString[i]; if (CharUnicodeInfo.GetUnicodeCategory(c) != UnicodeCategory.NonSpacingMark) stringBuilder.Append(c); } return stringBuilder.ToString(); } (Modified … Read more
Is it irrational to sanitize random character strings for curse words? [closed]
Don’t generate random strings with vowels and then you don’t have to worry about curse words.