Wed May 10 08:32:00 UTC 2023 inscode

上级 ad3482d9
print('欢迎来到 InsCode')
from threading import Thread
from time import sleep, ctime
import pandas as pd
# 读取csv文件
data = pd.read_csv('data.csv')
class MyClass(object):
# 显示前5行数据
print(data.head())
def func(self,name,sec):
print('---开始---', name, '时间', ctime())
sleep(sec)
print('***结束***', name, '时间', ctime())
# 获取数据集的形状
print(data.shape)
def main():
# 创建 Thread 实例
t1 = Thread(target=MyClass().func, args=(1, 1))
t2 = Thread(target=MyClass().func, args=(2, 2))
# 对数据进行描述性统计
print(data.describe())
# 启动线程运行
t1.start()
t2.start()
# 画出数据分布直方图
data.hist()
# 等待所有线程执行完毕
t1.join() # join() 等待线程终止,要不然一直挂起
t2.join()
# 保存处理过的数据为新的csv文件
data.to_csv('processed_data.csv', index=False)
if __name__=="__main__":
main()
\ No newline at end of file
certifi==2019.11.28
chardet==3.0.4
dbus-python==1.2.16
distro-info===0.23ubuntu1
docopt==0.6.2
idna==2.8
pipreqs==0.4.13
PyGObject==3.36.0
python-apt==2.0.1+ubuntu0.20.4.1
requests==2.22.0
requests-unixsocket==0.2.0
six==1.14.0
unattended-upgrades==0.1
urllib3==1.25.8
yarg==0.1.9
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册