I need to create Data Frame in Python Pandas with 100 rows with random values consisting of 10 elementary numbers.
So as a result I need something like below "col1" has to be as date type string:
col1
---------
1233459857
8463746781
9084756289
...
How can I do that in python pandas ?
>Solution :
To ensure that values beginning with one or more zeros are properly formatted, we can create values of data type string with zero padding to 10 places:
rng = np.random.default_rng()
df = pd.DataFrame(pd.Series(rng.integers(0, 10**10, size=100)).apply(lambda n: f'{n:0>10}'), columns=['col1'])
Output:
col1
0 9448137321
1 9080789825
2 0131300041
3 6795692128
4 5236197395
.. ...
95 0541351442
96 6920748551
97 9563382744
98 2385042247
99 3736754262