shao
This commit is contained in:
parent
39ace236f4
commit
105837804d
|
@ -0,0 +1,39 @@
|
|||
import threading
|
||||
import time
|
||||
|
||||
|
||||
def thread_test1(a):
|
||||
time.sleep(10)
|
||||
print("thread_pool_list111: ",a)
|
||||
|
||||
def thread_test2(a):
|
||||
time.sleep(10)
|
||||
print("thread_pool_list2222: ",a)
|
||||
|
||||
def main_model():
|
||||
print('aaa')
|
||||
|
||||
thread_pool_list111 = []
|
||||
thread_pool_list2222 = []
|
||||
'''开启多线程n个'''
|
||||
n = 5
|
||||
for i in range(n):
|
||||
t = threading.Thread(target=thread_test1, args=(i,))
|
||||
thread_pool_list111.append(t)
|
||||
|
||||
for i in range(n):
|
||||
t = threading.Thread(target=thread_test2, args=(i,))
|
||||
thread_pool_list2222.append(t)
|
||||
'''一个一个启动线程'''
|
||||
for t in thread_pool_list111:
|
||||
t.start()
|
||||
for t in thread_pool_list2222:
|
||||
t.start()
|
||||
|
||||
'''线程同步,也就是需要两个线程都跑完后,才继续跑主线程;反之则直接跑主线程,不需要等这两个跑完才跑主线程'''
|
||||
for t in thread_pool_list111:
|
||||
t.join()
|
||||
print('bbb')
|
||||
|
||||
if __name__ == '__main__':
|
||||
main_model()
|
|
@ -0,0 +1,12 @@
|
|||
from sklearn.datasets import load_iris
|
||||
import pandas as pd
|
||||
from pandasql import sqldf
|
||||
from pandasql import load_meat, load_births
|
||||
import re
|
||||
|
||||
births = load_births()
|
||||
meat = load_meat()
|
||||
iris = load_iris()
|
||||
iris_df = pd.DataFrame(iris.data, columns=iris.feature_names)
|
||||
|
||||
print(sqldf("SELECT * FROM iris_df where species = 'virginica'", locals()))
|
|
@ -0,0 +1,65 @@
|
|||
x,y,type
|
||||
0.0,86.0,positionHuman
|
||||
-150.0,0.0,positionLion1
|
||||
150.0,0.0,positionLion2
|
||||
0.0,260.0,positionLion3
|
||||
-4.999999999999998,77.33974596215562,positionHuman
|
||||
-136.76494892984817,7.059279224571922,positionLion1
|
||||
132.10406128097515,8.929466801825685,positionLion2
|
||||
-0.5472594840112444,240.0074887255963,positionLion3
|
||||
-9.226182617406991,68.27666809178912,positionHuman
|
||||
-123.24205264706627,13.550140194052265,positionLion1
|
||||
113.6638834589337,16.672840865597266,positionLion2
|
||||
-1.5567301122140142,220.03298074540325,positionLion3
|
||||
-12.646384050663677,58.87974188393004,positionHuman
|
||||
-109.36263005265471,19.238868386340744,positionLion1
|
||||
94.69488470565736,23.01138062631512,positionLion2
|
||||
-2.929769817164897,200.0801673606039,positionLion3
|
||||
-15.234574501688884,49.22048362103935,positionHuman
|
||||
-95.07013823269817,23.791304830320566,positionLion1
|
||||
75.24017382138524,27.64972347795774,positionLion2
|
||||
-4.55566176012823,180.14636502914172,positionLion3
|
||||
-16.97105627835819,39.372406090917266,positionHuman
|
||||
-80.36002744767515,26.726034918820986,positionLion1
|
||||
55.399857594326676,30.171994678744138,positionLion2
|
||||
-6.312718258451055,160.22369571848705,positionLion3
|
||||
-17.842613705834776,29.41045910999981,positionHuman
|
||||
-65.37383642465126,27.369524329330893,positionLion1
|
||||
35.4009385781504,29.96405674467876,positionLion2
|
||||
-8.068713135870544,140.30093280792477,positionLion3
|
||||
-17.84261370583478,19.41045910999981,positionHuman
|
||||
-50.57980917678932,24.892276301878162,positionLion1
|
||||
15.782614469524404,26.075437559298948,positionLion2
|
||||
-9.680438527573449,120.36598005499003,positionLion3
|
||||
-16.971056278358198,9.448512129082355,positionHuman
|
||||
-36.94994958055725,18.629135924479563,positionLion1
|
||||
-2.0511299646696806,17.022396111484213,positionLion2
|
||||
-10.99221013040813,100.40904503825972,positionLion3
|
||||
-15.234574501688895,-0.3995654010397267,positionHuman
|
||||
-25.668446137631694,8.743404789795653,positionLion1
|
||||
-14.119551140086138,1.0739413169669803,positionLion2
|
||||
-11.83313288558095,80.42673163565709,positionLion3
|
||||
-12.646384050663688,-10.05882366393041,positionHuman
|
||||
-17.128020134467874,-3.5879018597238233,positionLion1
|
||||
-11.495879273868582,-18.75322050560406,positionLion2
|
||||
-12.01287833073576,60.427539362594004,positionLion3
|
||||
-9.226182617407002,-19.455749871789493,positionHuman
|
||||
-10.441546065479782,-17.015152677547622,positionLion1
|
||||
7.609828528371047,-24.66692741205791,positionLion2
|
||||
-11.31561068616334,40.43969761237413,positionLion3
|
||||
-5.000000000000007,-28.51882774215599,positionHuman
|
||||
-4.0275329149094174,-30.574667244976297,positionLion1
|
||||
-11.517670333423897,-30.509768098918467,positionLion2
|
||||
-9.491532030128528,20.52305288851067,positionLion3
|
||||
-1.7763568394002505e-15,-37.179081780000374,positionHuman
|
||||
3.78221577568904,-43.381221246334185,positionLion1
|
||||
5.79008074459631,-40.53183139054113,positionLion2
|
||||
-6.245318838805734,0.7882587442465336,positionLion3
|
||||
5.735764363510464,-45.37060222289029,positionHuman
|
||||
14.291993288118316,-54.08377125272219,positionLion1
|
||||
5.565590016707294,-60.53057144868209,positionLion2
|
||||
-1.2205855728480914,-18.570255031505436,positionLion3
|
||||
12.163640460375863,-53.03104665408007,positionHuman
|
||||
0.8467729102914454,-47.433504416596804,positionLion1
|
||||
18.776419823396537,-45.514780566457766,positionLion2
|
||||
6.020259513780146,-37.21348872181389,positionLion3
|
|
|
@ -1,33 +0,0 @@
|
|||
# 5.机器人从原点(0,0)开始在平面中移动。 机器人可以通过给定的步骤向上,向下,向左和向右移动。
|
||||
# 机器人运动的痕迹如下所示: UP 5 DOWN 3 LETF 3 RIGHT 2 方向之后的数字是步骤。
|
||||
# 请编写一个程序来计算一系列运动和原点之后距当前位置的距离。
|
||||
# 如果距离是浮点数,则只打印最接近的整数。
|
||||
# 例:如果给出以下元组作为程序的输入:
|
||||
# UP 5 DOWN 3 LETF 3 RIGHT 2 然后,程序的输出应该是:2
|
||||
|
||||
import turtle
|
||||
import math
|
||||
import time
|
||||
print("请输入:")
|
||||
str=input()
|
||||
lis=str.split(" ")
|
||||
for i in range(0,len(lis)-1):
|
||||
if lis[i]=='UP':
|
||||
turtle.left(90)
|
||||
turtle.fd(int(lis[i+1]))
|
||||
turtle.setheading(0)
|
||||
if lis[i]=='DOWN':
|
||||
turtle.right(90)
|
||||
turtle.fd(int(lis[i+1]))
|
||||
turtle.setheading(0)
|
||||
if lis[i]=='LETF':
|
||||
turtle.left(180)
|
||||
turtle.fd(int(lis[i+1]))
|
||||
turtle.setheading(0)
|
||||
if lis[i]=='RIGHT':
|
||||
turtle.fd(int(lis[i+1]))
|
||||
#pos=turtle.position()
|
||||
# print(pos)
|
||||
# dis=math.sqrt(math.pow((pos[0]-0.0),2)+math.pow((pos[1]-0.0),2))
|
||||
# print(round(dis))
|
||||
|
|
@ -31,4 +31,4 @@ turtle.setheading(angle1)
|
|||
turtle.forward(15)
|
||||
lion1 = turtle.position()
|
||||
|
||||
time.sleep(10)
|
||||
turtle.done()
|
|
@ -0,0 +1,58 @@
|
|||
# 设有三条鳄鱼ABC分别站在等边三角形的三个角上,一个人站在三角形的正中间。
|
||||
# 每条鳄鱼和人的距离为100米,人的奔跑速度是10m/s鳄鱼A的奔跑速度是15m/s鳄鱼B和C的奔跑速度是20m/s。
|
||||
# 问:这个人最多还能活几秒?
|
||||
|
||||
|
||||
# 贪心算法
|
||||
#
|
||||
# 贪心算法(又称贪婪算法)是指,在对问题求解时,总是做出在当前看来是最好的选择。也就是说,不从整体最优上加以考虑,他所做出的是在某种意义上的局部最优解。
|
||||
#
|
||||
# 我的做法是:每过一段时间(比如0.1秒)做一次判断,选择此刻延直线距离运动到人 所需时间最短的那只鳄鱼,使人下一时间段所奔跑的方向为背离此鳄鱼的方向。
|
||||
# 程序中以人为原点建立平面直角坐标系,输出每个时间点人和鳄鱼的坐标。当任意一只鳄鱼在下一时间段内,追上人所需时间小于单位时间,程序结束,并输出人奔跑的总时间。
|
||||
# 将人和鳄鱼的所有时刻的坐标写入文件,用来画出运动轨迹。
|
||||
|
||||
import turtle
|
||||
|
||||
positionHuman = (0.00, 86.00)
|
||||
positionLion1 = (-150.00, 0.00)
|
||||
positionLion2 = (150.00, 0.00)
|
||||
positionLion3 = (0.00, 260.00)
|
||||
escapeDregree = 240
|
||||
|
||||
turtle.pensize(3)
|
||||
for x in range(100):
|
||||
turtle.color("black")
|
||||
turtle.penup()
|
||||
turtle.goto(positionHuman)
|
||||
turtle.pendown()
|
||||
turtle.setheading(escapeDregree)
|
||||
turtle.fd(10)
|
||||
|
||||
positionHuman = turtle.position()
|
||||
|
||||
turtle.color("green")
|
||||
turtle.penup()
|
||||
turtle.goto(positionLion1)
|
||||
turtle.pendown()
|
||||
positionLion1ToHuman = turtle.towards(positionHuman)
|
||||
turtle.setheading(positionLion1ToHuman)
|
||||
turtle.forward(15)
|
||||
positionLion1 = turtle.position()
|
||||
|
||||
turtle.color("red")
|
||||
turtle.penup()
|
||||
turtle.goto(positionLion2)
|
||||
turtle.pendown()
|
||||
positionLion2ToHuman = turtle.towards(positionHuman)
|
||||
turtle.setheading(positionLion2ToHuman)
|
||||
turtle.forward(20)
|
||||
positionLion2 = turtle.position()
|
||||
|
||||
turtle.color("brown")
|
||||
turtle.penup()
|
||||
turtle.goto(positionLion3)
|
||||
turtle.pendown()
|
||||
positionLion3ToHuman = turtle.towards(positionHuman)
|
||||
turtle.setheading(positionLion3ToHuman)
|
||||
turtle.forward(20)
|
||||
positionLion3 = turtle.position()
|
|
@ -0,0 +1,58 @@
|
|||
# 设有三条鳄鱼ABC分别站在等边三角形的三个角上,一个人站在三角形的正中间。
|
||||
# 每条鳄鱼和人的距离为100米,人的奔跑速度是10m/s鳄鱼A的奔跑速度是15m/s鳄鱼B和C的奔跑速度是20m/s。
|
||||
# 问:这个人最多还能活几秒?
|
||||
|
||||
|
||||
# 贪心算法
|
||||
#
|
||||
# 贪心算法(又称贪婪算法)是指,在对问题求解时,总是做出在当前看来是最好的选择。也就是说,不从整体最优上加以考虑,他所做出的是在某种意义上的局部最优解。
|
||||
#
|
||||
# 我的做法是:每过一段时间(比如0.1秒)做一次判断,选择此刻延直线距离运动到人 所需时间最短的那只鳄鱼,使人下一时间段所奔跑的方向为背离此鳄鱼的方向。
|
||||
# 程序中以人为原点建立平面直角坐标系,输出每个时间点人和鳄鱼的坐标。当任意一只鳄鱼在下一时间段内,追上人所需时间小于单位时间,程序结束,并输出人奔跑的总时间。
|
||||
# 将人和鳄鱼的所有时刻的坐标写入文件,用来画出运动轨迹。
|
||||
|
||||
import turtle
|
||||
|
||||
positionHuman = (0.00, 86.00)
|
||||
positionLion1 = (-150.00, 0.00)
|
||||
positionLion2 = (150.00, 0.00)
|
||||
positionLion3 = (0.00, 260.00)
|
||||
escapeDregree = 240
|
||||
|
||||
turtle.pensize(3)
|
||||
for x in range(100):
|
||||
turtle.color("black")
|
||||
turtle.penup()
|
||||
turtle.goto(positionHuman)
|
||||
turtle.pendown()
|
||||
turtle.setheading(escapeDregree+x*5)
|
||||
turtle.fd(10)
|
||||
|
||||
positionHuman = turtle.position()
|
||||
|
||||
turtle.color("green")
|
||||
turtle.penup()
|
||||
turtle.goto(positionLion1)
|
||||
turtle.pendown()
|
||||
positionLion1ToHuman = turtle.towards(positionHuman)
|
||||
turtle.setheading(positionLion1ToHuman)
|
||||
turtle.forward(15)
|
||||
positionLion1 = turtle.position()
|
||||
|
||||
turtle.color("red")
|
||||
turtle.penup()
|
||||
turtle.goto(positionLion2)
|
||||
turtle.pendown()
|
||||
positionLion2ToHuman = turtle.towards(positionHuman)
|
||||
turtle.setheading(positionLion2ToHuman)
|
||||
turtle.forward(20)
|
||||
positionLion2 = turtle.position()
|
||||
|
||||
turtle.color("brown")
|
||||
turtle.penup()
|
||||
turtle.goto(positionLion3)
|
||||
turtle.pendown()
|
||||
positionLion3ToHuman = turtle.towards(positionHuman)
|
||||
turtle.setheading(positionLion3ToHuman)
|
||||
turtle.forward(20)
|
||||
positionLion3 = turtle.position()
|
|
@ -0,0 +1,63 @@
|
|||
# 设有三条鳄鱼ABC分别站在等边三角形的三个角上,一个人站在三角形的正中间。
|
||||
# 每条鳄鱼和人的距离为100米,人的奔跑速度是10m/s鳄鱼A的奔跑速度是15m/s鳄鱼B和C的奔跑速度是20m/s。
|
||||
# 问:这个人最多还能活几秒?
|
||||
|
||||
|
||||
# 贪心算法
|
||||
#
|
||||
# 贪心算法(又称贪婪算法)是指,在对问题求解时,总是做出在当前看来是最好的选择。也就是说,不从整体最优上加以考虑,他所做出的是在某种意义上的局部最优解。
|
||||
#
|
||||
# 我的做法是:每过一段时间(比如0.1秒)做一次判断,选择此刻延直线距离运动到人 所需时间最短的那只鳄鱼,使人下一时间段所奔跑的方向为背离此鳄鱼的方向。
|
||||
# 程序中以人为原点建立平面直角坐标系,输出每个时间点人和鳄鱼的坐标。当任意一只鳄鱼在下一时间段内,追上人所需时间小于单位时间,程序结束,并输出人奔跑的总时间。
|
||||
# 将人和鳄鱼的所有时刻的坐标写入文件,用来画出运动轨迹。
|
||||
|
||||
import turtle
|
||||
|
||||
positionHuman = (0.00, 86.00)
|
||||
positionLion1 = (-150.00, 0.00)
|
||||
positionLion2 = (150.00, 0.00)
|
||||
positionLion3 = (0.00, 260.00)
|
||||
escapeDregree = 240
|
||||
|
||||
turtle.pensize(3)
|
||||
for x in range(100):
|
||||
turtle.color("black")
|
||||
turtle.penup()
|
||||
turtle.goto(positionHuman)
|
||||
turtle.pendown()
|
||||
turtle.setheading(escapeDregree+x*5)
|
||||
turtle.fd(10)
|
||||
|
||||
positionHuman = turtle.position()
|
||||
|
||||
turtle.color("green")
|
||||
turtle.penup()
|
||||
turtle.goto(positionLion1)
|
||||
turtle.pendown()
|
||||
positionLion1ToHuman = turtle.towards(positionHuman)
|
||||
turtle.setheading(positionLion1ToHuman)
|
||||
turtle.forward(15)
|
||||
positionLion1 = turtle.position()
|
||||
|
||||
turtle.color("red")
|
||||
turtle.penup()
|
||||
turtle.goto(positionLion2)
|
||||
turtle.pendown()
|
||||
positionLion2ToHuman = turtle.towards(positionHuman)
|
||||
turtle.setheading(positionLion2ToHuman)
|
||||
turtle.forward(20)
|
||||
positionLion2 = turtle.position()
|
||||
|
||||
turtle.color("brown")
|
||||
turtle.penup()
|
||||
turtle.goto(positionLion3)
|
||||
turtle.pendown()
|
||||
positionLion3ToHuman = turtle.towards(positionHuman)
|
||||
turtle.setheading(positionLion3ToHuman)
|
||||
turtle.forward(20)
|
||||
positionLion3 = turtle.position()
|
||||
d3,d2,d1 = turtle.distance(positionHuman,positionLion3),turtle.distance(positionHuman,positionLion2),turtle.distance(positionHuman,positionLion1)
|
||||
if(d1<=20 or d2<=20 or d3<=20):
|
||||
print(d1,d2,d3,x)
|
||||
break
|
||||
|
|
@ -0,0 +1,116 @@
|
|||
# 设有三条鳄鱼ABC分别站在等边三角形的三个角上,一个人站在三角形的正中间。
|
||||
# 每条鳄鱼和人的距离为100米,人的奔跑速度是10m/s鳄鱼A的奔跑速度是15m/s鳄鱼B和C的奔跑速度是20m/s。
|
||||
# 问:这个人最多还能活几秒?
|
||||
|
||||
|
||||
# 贪心算法
|
||||
#
|
||||
# 贪心算法(又称贪婪算法)是指,在对问题求解时,总是做出在当前看来是最好的选择。也就是说,不从整体最优上加以考虑,他所做出的是在某种意义上的局部最优解。
|
||||
#
|
||||
# 我的做法是:每过一段时间(比如0.1秒)做一次判断,选择此刻延直线距离运动到人 所需时间最短的那只鳄鱼,使人下一时间段所奔跑的方向为背离此鳄鱼的方向。
|
||||
# 程序中以人为原点建立平面直角坐标系,输出每个时间点人和鳄鱼的坐标。当任意一只鳄鱼在下一时间段内,追上人所需时间小于单位时间,程序结束,并输出人奔跑的总时间。
|
||||
# 将人和鳄鱼的所有时刻的坐标写入文件,用来画出运动轨迹。
|
||||
import pandas as pd
|
||||
import turtle
|
||||
|
||||
positionHuman = (0.00, 86.00)
|
||||
positionLion1 = (-150.00, 0.00)
|
||||
positionLion2 = (150.00, 0.00)
|
||||
positionLion3 = (0.00, 260.00)
|
||||
escapeDregree = 240
|
||||
|
||||
df = pd.DataFrame(
|
||||
{"x" : [positionHuman[0]],
|
||||
"y" : [positionHuman[1]],
|
||||
"type": "positionHuman"}
|
||||
)
|
||||
|
||||
df1 = pd.DataFrame(
|
||||
{"x" : [positionLion1[0]],
|
||||
"y" : [positionLion1[1]],
|
||||
"type": "positionLion1"}
|
||||
)
|
||||
|
||||
df2 = pd.DataFrame(
|
||||
{"x" : [positionLion2[0]],
|
||||
"y" : [positionLion2[1]],
|
||||
"type": "positionLion2"}
|
||||
)
|
||||
|
||||
df3 = pd.DataFrame(
|
||||
{"x" : [positionLion3[0]],
|
||||
"y" : [positionLion3[1]],
|
||||
"type": "positionLion3"}
|
||||
)
|
||||
dfAll = pd.concat([df,df1,df2,df3])
|
||||
|
||||
|
||||
turtle.pensize(3)
|
||||
for x in range(100):
|
||||
turtle.color("black")
|
||||
turtle.penup()
|
||||
turtle.goto(positionHuman)
|
||||
turtle.pendown()
|
||||
turtle.setheading(escapeDregree+x*5)
|
||||
turtle.fd(10)
|
||||
|
||||
positionHuman = turtle.position()
|
||||
|
||||
turtle.color("green")
|
||||
turtle.penup()
|
||||
turtle.goto(positionLion1)
|
||||
turtle.pendown()
|
||||
positionLion1ToHuman = turtle.towards(positionHuman)
|
||||
turtle.setheading(positionLion1ToHuman)
|
||||
turtle.forward(15)
|
||||
positionLion1 = turtle.position()
|
||||
|
||||
turtle.color("red")
|
||||
turtle.penup()
|
||||
turtle.goto(positionLion2)
|
||||
turtle.pendown()
|
||||
positionLion2ToHuman = turtle.towards(positionHuman)
|
||||
turtle.setheading(positionLion2ToHuman)
|
||||
turtle.forward(20)
|
||||
positionLion2 = turtle.position()
|
||||
|
||||
turtle.color("brown")
|
||||
turtle.penup()
|
||||
turtle.goto(positionLion3)
|
||||
turtle.pendown()
|
||||
positionLion3ToHuman = turtle.towards(positionHuman)
|
||||
turtle.setheading(positionLion3ToHuman)
|
||||
turtle.forward(20)
|
||||
positionLion3 = turtle.position()
|
||||
d3,d2,d1 = turtle.distance(positionHuman,positionLion3),turtle.distance(positionHuman,positionLion2),turtle.distance(positionHuman,positionLion1)
|
||||
|
||||
df = pd.DataFrame(
|
||||
{"x": [positionHuman[0]],
|
||||
"y": [positionHuman[1]],
|
||||
"type": "positionHuman"}
|
||||
)
|
||||
|
||||
df1 = pd.DataFrame(
|
||||
{"x": [positionLion1[0]],
|
||||
"y": [positionLion1[1]],
|
||||
"type": "positionLion1"}
|
||||
)
|
||||
|
||||
df2 = pd.DataFrame(
|
||||
{"x": [positionLion2[0]],
|
||||
"y": [positionLion2[1]],
|
||||
"type": "positionLion2"}
|
||||
)
|
||||
|
||||
df3 = pd.DataFrame(
|
||||
{"x": [positionLion3[0]],
|
||||
"y": [positionLion3[1]],
|
||||
"type": "positionLion3"}
|
||||
)
|
||||
dfAll = pd.concat([dfAll,df, df1, df2, df3])
|
||||
|
||||
if(d1<=20 or d2<=20 or d3<=20):
|
||||
print(d1,d2,d3,x)
|
||||
dfAll.to_csv("p.csv",index=False)
|
||||
break
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
import pandas as pd
|
||||
import plotly.express as px
|
||||
|
||||
df = pd.read_csv("p.csv")
|
||||
|
||||
fig = px.line(df, x="x", y="y", color="type", title="A Plotly Express Figure")
|
||||
# If you print the figure, you'll see that it's just a regular figure with data and layout
|
||||
# print(fig)
|
||||
|
||||
fig.show()
|
|
@ -0,0 +1,34 @@
|
|||
# 设有三条鳄鱼ABC分别站在等边三角形的三个角上,一个人站在三角形的正中间。
|
||||
# 每条鳄鱼和人的距离为100米,人的奔跑速度是10m/s鳄鱼A的奔跑速度是15m/s鳄鱼B和C的奔跑速度是20m/s。
|
||||
# 问:这个人最多还能活几秒?
|
||||
|
||||
|
||||
# 贪心算法
|
||||
#
|
||||
# 贪心算法(又称贪婪算法)是指,在对问题求解时,总是做出在当前看来是最好的选择。也就是说,不从整体最优上加以考虑,他所做出的是在某种意义上的局部最优解。
|
||||
#
|
||||
# 我的做法是:每过一段时间(比如0.1秒)做一次判断,选择此刻延直线距离运动到人 所需时间最短的那只鳄鱼,使人下一时间段所奔跑的方向为背离此鳄鱼的方向。
|
||||
# 程序中以人为原点建立平面直角坐标系,输出每个时间点人和鳄鱼的坐标。当任意一只鳄鱼在下一时间段内,追上人所需时间小于单位时间,程序结束,并输出人奔跑的总时间。
|
||||
# 将人和鳄鱼的所有时刻的坐标写入文件,用来画出运动轨迹。
|
||||
|
||||
import turtle
|
||||
import pandas as pd
|
||||
|
||||
positionHuman = (0.00, 86.00)
|
||||
positionLion1 = (-150.00, 0.00)
|
||||
positionLion2 = (150.00, 0.00)
|
||||
positionLion3 = (0.00, 260.00)
|
||||
escapeDregree = 240
|
||||
|
||||
df = pd.DataFrame(
|
||||
{"x" : [positionHuman[0]],
|
||||
"y" : [positionHuman[1]],
|
||||
"type": "positionHuman"}
|
||||
)
|
||||
df2 = pd.DataFrame(
|
||||
{"x" : [1],
|
||||
"y" : [1],
|
||||
"type": "positionHuman"}
|
||||
)
|
||||
df = pd.concat([df,df2])
|
||||
df.to_csv("p.csv")
|
|
@ -1,17 +1,20 @@
|
|||
|
||||
import pandas as pd
|
||||
|
||||
df = pd.read_csv('..\data\learn_pandas.csv')
|
||||
df_demo = df[['Height', 'Weight']]
|
||||
print(df_demo.mean(),df_demo.max(),df_demo.quantile(0.75))
|
||||
import plotly.express as px
|
||||
|
||||
df_demo = px.data.iris()
|
||||
# print(df_demo.mean(),df_demo.max(),df_demo.quantile(0.75))
|
||||
|
||||
# 此外,需要介绍的是 quantile, count, idxmax 这三个函数,它们分别返回的是
|
||||
# 分位数、
|
||||
# 非缺失值个数、
|
||||
# 最大值对应的索引
|
||||
|
||||
print(df_demo.mean(axis=1).head())
|
||||
print("mena",df_demo.mean(axis=1).head())
|
||||
#
|
||||
df_demo = df_demo[['sepal_length','sepal_width','petal_length']]
|
||||
print(df_demo.drop_duplicates(['sepal_length', 'sepal_width']))
|
||||
|
||||
|
||||
df_demo = df[['Gender','Transfer','Name']]
|
||||
print(df_demo.drop_duplicates(['Gender', 'Transfer']))
|
||||
|
||||
|
|
Binary file not shown.
|
@ -0,0 +1,19 @@
|
|||
import pandas as pd
|
||||
|
||||
df = pd.DataFrame(
|
||||
{"x" : [0],
|
||||
"y" : [1],
|
||||
"type": "positionHuman"}
|
||||
)
|
||||
|
||||
df1 = pd.DataFrame(
|
||||
{"x" : [2],
|
||||
"y" : [3],
|
||||
"type": "positionLion1"}
|
||||
)
|
||||
df = pd.concat([df,df1],axis=1)
|
||||
print(df)
|
||||
# df = df.pivot(columns='x', values='x')
|
||||
# df = pd.melt(df)
|
||||
# print("pivot",df)
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
import plotly.express as px
|
||||
|
||||
df = px.data.iris()
|
||||
print(df.head(10))
|
||||
|
||||
# df = px.data.wind()
|
||||
# print(df.head(10))
|
||||
#
|
||||
# df = px.data.carshare()
|
||||
# print(df.head(10))
|
||||
# fig = px.scatter(df, x="sepal_width", y="sepal_length", color="species", title="A Plotly Express Figure")
|
||||
# # If you print the figure, you'll see that it's just a regular figure with data and layout
|
||||
# # print(fig)
|
||||
#
|
||||
# fig.show()
|
||||
|
||||
# print(df.iloc[10:20])
|
||||
# print(df.sample(frac=0.01))
|
||||
# print(df.nlargest(10,'sepal_width'))
|
||||
# print(df.loc[df['sepal_width'] > 3, ['sepal_width', 'petal_length']])
|
||||
print(df.iat[1, 3])
|
|
@ -0,0 +1,16 @@
|
|||
import plotly.express as px
|
||||
|
||||
import pandas as pd
|
||||
import numpy as np
|
||||
np.random.seed(1)
|
||||
|
||||
N = 100000
|
||||
|
||||
df = pd.DataFrame(dict(x=np.random.randn(N),
|
||||
y=np.random.randn(N)))
|
||||
|
||||
fig = px.scatter(df, x="x", y="y", render_mode='webgl')
|
||||
|
||||
fig.update_traces(marker_line=dict(width=1, color='DarkSlateGray'))
|
||||
|
||||
fig.show()
|
Loading…
Reference in New Issue