You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
620 B
31 lines
620 B
import pandas as pd
|
|
import random
|
|
from itertools import product
|
|
|
|
names = ['Alice', 'Bob', 'Chunk', 'David', 'Eva', 'Frank']
|
|
course = ['A', 'B', 'C']
|
|
age = [random.randint(18, 20) for _ in range(len(names))]
|
|
|
|
|
|
stu = pd.DataFrame({
|
|
'name':names,
|
|
'sex':[random.randint(0, 1) for _ in range(len(names))],
|
|
'age':age,
|
|
})
|
|
|
|
stu.to_csv('data.csv')
|
|
|
|
p = product(names, course)
|
|
names.clear()
|
|
course.clear()
|
|
for x, y in p:
|
|
names.append(x)
|
|
course.append(y)
|
|
|
|
score = pd.DataFrame({
|
|
'name':names,
|
|
'course':course,
|
|
'score':[random.randint(0, 100) for _ in range(len(names))]
|
|
})
|
|
|
|
score.to_csv('score.csv') |