Question: I need to concat two json response (attach the second to the first)
because i have a model class which is a mix of fields from the first and second response.

My code:

```
List nextR = [];
final response = await dio.get(URL);
final result = response.data;
final response2 = await dio.get(URL);
final result2 = response2.data;
nextR.add(result);

```

i tried `nextR.join(...)` and `nextR.extend(...)` but it does not work

Now i receive this error (For Ezra solution)

```
Unhandled Exception: FormatException: Unexpected character (at character 2)
E/flutter (26428): {example:.......

```

The first response is:

```
{
    "SData": {
        "series": "example",
        "Table": {
            "year": "2021",
            "Info": [
                {
                    "year": "2021",
                    "turn": "1",
                    "date": "2021-01-01",
                    "time": "23:00:00Z"
                },
            ]
        }
    }
}

```

The second one is:

```
{
    "SData": {
        "series": "example",
        "Table": {
            "year": "2021",
            "Info": [
                {
                    "year": "2021",
                    "Results": [
                        {
                            "number": "18",
                            "ac": "none",
                            "Time": {
                                "time": "no time"
                            },
                        },
                    ]
                }
            ]
        }
    }
}

```

I want to merge "Results" into the first response

Answer: 
You can first form bins from `breaks.time` and then assign categories to `values.time` with these bins using [`pd.cut`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.cut.html):

```
import numpy as np

# intervals to fall into
bins = [-np.inf, *breaks.time, +np.inf]

# distinct labels of 0..N-1
labels = np.arange(len(bins) - 1)

# form a new column in `values` with assigned categories
values["cats"] = pd.cut(values.time, bins=bins, labels=labels)

```

At this point `values` looks like:

```
>>> values

   time     value cats
0     0  10312435    0
1     9  45924523    1
2    11  43423434    1
3    20  42343552    2

```

Now we can group by `cats` and, for example, form a list of dataframes:

```
# no need for `cats` column anymore, so we drop it when putting in
frames_list = [frame.drop(columns="cats")
               for _, frame in values.groupby("cats")[["time", "value"]]]

```

We can access the frames as

```
>>> frames_list[0]

   time     value
0     0  10312435

>>> frames_list[1]

   time     value
1     9  45924523
2    11  43423434

>>> frames_list[2]

   time     value
3    20  42343552

```
I came up with the following, based on [Pandas split DataFrame by column value](https://stackoverflow.com/questions/33742588/pandas-split-dataframe-by-column-value)

```
sim_dist_right = pandas.read_csv('sim/dist_right.csv', comment='#')
sim_round_indicator = pandas.read_csv('sim/round_indicator.csv', comment='#')

round_list = []
for index, row in sim_round_indicator.iterrows():
    print("splitting at " + str(row['time']))
    df_sep = sim_dist_right[sim_dist_right['time'] < row['time']]

    round_list.append(df_sep)
    print("separated a batch of " + str(len(df_sep)) + " elements")

    df_over = sim_dist_right[sim_dist_right['time'] >= row['time']]
    print(str(len(df_over)) + " elements over")

    sim_dist_right = df_over

print("splitted values into " + str(len(round_list)) + " batches")

```