repeat

Repeat rows in a pandas DataFrame based on column value

陌路散爱 提交于 2020-08-20 11:30:09
问题 I have the following df: code . role . persons 123 . Janitor . 3 123 . Analyst . 2 321 . Vallet . 2 321 . Auditor . 5 The first line means that I have 3 persons with the role Janitors. My problem is that I would need to have one line for each person. My df should look like this: df: code . role . persons 123 . Janitor . 3 123 . Janitor . 3 123 . Janitor . 3 123 . Analyst . 2 123 . Analyst . 2 321 . Vallet . 2 321 . Vallet . 2 321 . Auditor . 5 321 . Auditor . 5 321 . Auditor . 5 321 . Auditor

Repeat rows in a pandas DataFrame based on column value

不打扰是莪最后的温柔 提交于 2020-08-20 11:30:08
问题 I have the following df: code . role . persons 123 . Janitor . 3 123 . Analyst . 2 321 . Vallet . 2 321 . Auditor . 5 The first line means that I have 3 persons with the role Janitors. My problem is that I would need to have one line for each person. My df should look like this: df: code . role . persons 123 . Janitor . 3 123 . Janitor . 3 123 . Janitor . 3 123 . Analyst . 2 123 . Analyst . 2 321 . Vallet . 2 321 . Vallet . 2 321 . Auditor . 5 321 . Auditor . 5 321 . Auditor . 5 321 . Auditor

Repeat ndarray n times [duplicate]

我的梦境 提交于 2020-07-04 03:04:48
问题 This question already has answers here : Repeating each element of a numpy array 5 times (2 answers) Closed last year . I have a numpy.ndarray with True / False : import numpy as np a = np.array([True, True, False]) I want: out = np.array([True, True, False, True, True, False, True, True, False]) I tried: np.repeat(a, 3, axis = 0) But it duplicates each element, I want to duplicate the all array. This is the closes I got: np.array([a for i in range(3)]) However, I want it to stay as 1D. Edit

Repeat ndarray n times [duplicate]

◇◆丶佛笑我妖孽 提交于 2020-07-04 03:04:06
问题 This question already has answers here : Repeating each element of a numpy array 5 times (2 answers) Closed last year . I have a numpy.ndarray with True / False : import numpy as np a = np.array([True, True, False]) I want: out = np.array([True, True, False, True, True, False, True, True, False]) I tried: np.repeat(a, 3, axis = 0) But it duplicates each element, I want to duplicate the all array. This is the closes I got: np.array([a for i in range(3)]) However, I want it to stay as 1D. Edit

How to denote at least one repetition in EBNF?

有些话、适合烂在心里 提交于 2020-04-18 06:27:10
问题 https://en.wikipedia.org/wiki/Extended_Backus–Naur_form The above article mentions that curly braces denote repetition of arbitrary times (incl. zero), while square brackets denote at most one repetition. What I want however, is at least one repetition - that is, a terminal or a nonterminal must appear at least once. Well I can describe it like that: production = nonterminal, { nonterminal }; But I thought the point of EBNF over BNF was to avoid the need of this kind of "hacks". The Wikipedia

Combination of a Collection with Repetitions

好久不见. 提交于 2020-02-06 04:19:06
问题 There are a lot of links on http://stackoverflow.com for how to do combinations: Generating combinations in c++ But these links presume to draw from an infinite set without repetition. When given a finite collection which does have repetition, these algorithms construct duplicates. For example you can see the accepted solution to the linked question failing on a test case I constructed here: http://ideone.com/M7CyFc Given the input set: vector<int> row {40, 40, 40, 50, 50, 60, 100}; I expect

Combination of a Collection with Repetitions

江枫思渺然 提交于 2020-02-06 04:19:05
问题 There are a lot of links on http://stackoverflow.com for how to do combinations: Generating combinations in c++ But these links presume to draw from an infinite set without repetition. When given a finite collection which does have repetition, these algorithms construct duplicates. For example you can see the accepted solution to the linked question failing on a test case I constructed here: http://ideone.com/M7CyFc Given the input set: vector<int> row {40, 40, 40, 50, 50, 60, 100}; I expect