1 回答
TA贡献1752条经验 获得超4个赞
您可以使用列表理解。
import pandas as pd
import datetime
import numpy as np
# List of Columns
n = 100
data = {
'ID': [i+1 for i in range(n)],
'Age': [np.random.randint(18, 65) for i in range(n)],
'City': [np.random.randint(2, 8)*1000 for i in range(n)],
'Telephone': [np.random.randint(11111111, 99999999) for i in range(n)]
}
# Create DataFrame
df = pd.DataFrame(data)
# Print the output.
print(df)
>>>
ID Age City Telephone
0 1 43 6000 25571478
1 2 60 5000 89030075
2 3 33 7000 41082092
3 4 21 7000 95900727
4 5 64 3000 51121306
.. ... ... ... ...
95 96 51 6000 21656354
96 97 46 3000 91976030
97 98 60 3000 58243519
98 99 41 3000 80755166
99 100 57 4000 96513484
[100 rows x 4 columns]
添加回答
举报