Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个包含 5 行和多列的文件,当程序读取它时,它应该生成 100 条记录,然后可以将其加载到数据库中。格式可以是excel或csv
让我们为您保存一个文件file.csv。将其读入数据帧并根据需要多次从中采样。将结果写入新的数据框或 csv。
file.csv
import pandas as pd df = pd.read_csv('file.csv') new_df = df.sample(n=100, replace=True) # n could be as big as you want # new df can now be exported new_df.to_csv('new_df.csv')