Selecting rows

With this df what is an efficient way to get a new df with two copies of the x==2 row and one copy of x==3 using a needed_rows vector?

x=[1,2,3]
y=[“a”,“b”,“c”]
df=DataFrame(x=x, y=y)

needed_rows=[2,2,3]

The new df would be:

3×2 DataFrame
Row │ x y
│ Int64 String
─────┼───────────────
1 │ 2 b
2 │ 2 b
3 │ 3 c

Thank you for the help!

julia> df[needed_rows, :]
3×2 DataFrame
 Row │ x      y
     │ Int64  String
─────┼───────────────
   1 │     2  b
   2 │     2  b
   3 │     3  c

Please make sure to enclose your code in triple backticks ``` to make copy/pasting easier.