> ## Content Index
> Fetch the complete content index at: https://datascientyst.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# How to Create a Pandas DataFrame of Random Integers
- URL: https://datascientyst.com/how-to-create-a-dataframe-of-random-integers-with-pandas/
- Published: 2021-06-22T10:15:47.000Z
- Updated: 2021-11-27T08:29:42.000Z
- Author: John D K
- Tags: Create

In this quick guide, we're going to create a Pandas DataFrame of random integers with arbitrary length.

```python
import numpy as np
import pandas as pd
import string

string.ascii_lowercase

n = 5
m = 7

cols = string.ascii_lowercase[:m]

df = pd.DataFrame(np.random.randint(0, n,size=(n , m)), columns=list(cols))

df

```

Explanation:

- n - number of the rows
- m - number of the columns. The columns will be named with latin letters in lowercase
- `np.random.randint` \- will be used to produce random integers in a range of n to m.

The produced DataFrame with random integer numbers is:

|   | a | b | c | d | e | f | g |
| - | - | - | - | - | - | - | - |
| 0 | 2 | 3 | 1 | 0 | 3 | 2 | 1 |
| 1 | 1 | 4 | 3 | 3 | 3 | 0 | 4 |
| 2 | 4 | 2 | 3 | 2 | 2 | 2 | 3 |
| 3 | 3 | 1 | 1 | 3 | 2 | 2 | 4 |
| 4 | 3 | 0 | 0 | 3 | 0 | 3 | 2 |