Using Pandas and NumPy, generate a 100,000-row dataset with columns ID (1 to 100000), a randomly selected sentence from a given list, a random cost between 0 and 100, and the sentence length; print the first 5 rows.
Asked in the Technical round 1 stage. Explain approach on paper first, then code in an online IDE. Reported follow-ups: given an LLM context window K, split the DataFrame into the minimum number of DataFrames so that total sentence length in each split does not exceed K, also considering minimum cost per split.
id, sentence, cost, and sentence_length.id ascending.sentence is NULL.| Column | Type | Description |
|---|---|---|
| idPK | INTEGER | Row identifier from 1 to 100000 |
| sentence | VARCHAR(255) | Randomly selected sentence text |
| cost | NUMERIC(5,2) | Random cost between 0 and 100 |
| sentence_length | INTEGER | Character length of the sentence |