About 145,000 results
Open links in new tab
  1. The groups () method in regular expressions in Python

    Nov 25, 2013 · group(0) stands for all matched string, hence abc, that is 3 groups a, b and c. group(i) stands for i'th group, and citing documentation. If a group matches multiple times, only the last match is accessible. hence group(1) stands for last match, c. Your + is interpreted as group repetation, if you want repeat [abc] inside group, move + into ...

  2. Grouping Functions by Using Classes in Python - Stack Overflow

    May 10, 2017 · You can define multiple classes in one file, and those classes can group related functions. But a python "module" is just the contents of a file; so you cannot define a module in code (and consequently cannot define multiple modules in one file). The workaround, making classes and decorating every function with @staticmethod, is awkward and smelly.

  3. module - Python, advice on grouping functions - Stack Overflow

    Apr 25, 2016 · You could group you functions into modules without creating a class to hold a bunch of static methods. you would only want to go that route if you felt there were instances of the class you were creating and there was a need to act outside the instance level (maybe on a list of instances or setting some global variable that is used in creation of the instances).

  4. python - Apply multiple functions to multiple groupby columns

    Now, if you had multiple columns that needed to interact together then you cannot use agg, which implicitly passes a Series to the aggregating function. When using apply the entire group as a DataFrame gets passed into the function. I recommend making a single custom function that returns a Series of all the aggregations.

  5. python - Apply function to pandas groupby - Stack Overflow

    Mar 13, 2013 · apply takes a function to apply to each value, not the series, and accepts kwargs. So, the values do not have the .size() method.

  6. python - What's the difference between groups and group in the …

    Feb 19, 2012 · groups() only returns any explicitly-captured groups in your regex (denoted by (round brackets ) in your regex), whereas group(0) returns the entire substring that's matched by your regex regardless of whether your expression has any capture groups. The first explicit capture in your regex is indicated by group(1) instead. Re follow-up edit:

  7. Python group by - Stack Overflow

    This is not very efficient, but it is Pythonic. Basically, work out the distinct groups by taking the set of group values, and then for each of these groups, get the items that are in that group. [ { "type": group, "items": [item[0] for item in input if item[1] == group] } for group in {item[1] for item in input} ]

  8. python - regular expression : group function - Stack Overflow

    Nov 19, 2015 · Python Regex and group function. 1. Python Regular Expression Multiple Groups. 0. Regular expression by ...

  9. Pandas: How to use get_group() with a groupby() based on a …

    Aug 9, 2018 · But get_group() returns an error: df3.groupby(by=lambda index: func(df3, index), sort=False).get_group(('A', 1)) NotImplementedError: isna is not defined for MultiIndex. I could iterate through the groupby and save the keys/values in a dictionary to access the groups by name, but that would be inefficient memory-wise.

  10. python - Groupby with User Defined Functions Pandas - Stack …

    Oct 27, 2013 · I understand that passing a function as a group key calls the function once per index value with the return values being used as the group names. What I can't figure out is how to call the function on column values. So I can do this: