-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
116 lines (100 loc) · 2.6 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
import pandas as pd
import numpy as np
# i = 1
# while i < 11:
# df_0 = pd.DataFrame(np.arange(i, i+4), columns=['a'])
# i = i+1
# print(df_0)
# print(np.arange(1, 5))
user_id = 1
lat_average = 22324
lon_average = 5645645
record_time = 2018
df_all = pd.DataFrame(columns=['user_id', 'lat', 'lon', 'record_time'])
dict_singleaggregateddata = {'user_id': [user_id], 'lat': [lat_average], 'lon': [lon_average], 'record_time': [record_time]}
df_singleaggregateddate = pd.DataFrame({'user_id': [user_id], 'lat': [lat_average], 'lon': [lon_average],
'record_time': [record_time]},
columns=['user_id', 'lat', 'lon', 'record_time'])
df_all = df_all.append(df_singleaggregateddate)
# print(df_all)
# #函数的参数
# ll = [1, 2, 3]
# print(*ll)
# print(ll)
#
# #keyword operand
# def person(name, age, **kw):
# print('name:' , name, 'age: ', age, 'other: ', kw)
#
# person('Bob', 35, city='Beijing') #不能是person('Bob', 35, 'Beijing')
#
# #可变参数:计算传入参数的乘积
# def product(*numbers):
# result = 1
# for n in numbers:
# result = result * n
# print(result)
#
# product(5, 6, 7, 9)
# # slice
# def trim(s):
# return s[1 : len(s)-1]
#
# str = 'helloworld'
# print(trim(str))
# # iteration
# def findMinAndMax(L):
# min = L[0]
# max = L[0]
# for item in L:
# if item < min:
# min = item
# elif item > max:
# max = item
# return min, max
#
# L = [5, 4, 3, 2, 1, 0, -9, 99]
# print(findMinAndMax(L))
#
# # ################ list comprehensions
# ll = [x * x for x in range(1, 11)]
# print(findMinAndMax(ll))
# li = range(1, 11)
# print(li)
# ll = list(range(1, 11))
# print(ll)
# import os # 导入os模块,模块的概念后面讲到
# dir = [d for d in os.listdir('.')]
# print(dir)
# L = ['Apple', 'IBM', 18, 'HellO', 'WoRld']
# l = [s.lower() for s in L if isinstance(s, str) is True]
# print(l)
# 杨辉三角: failed....
# def triangles():
# n = 0
# lt = []
# lt.append([1])
# lt.append([1,1])
# while True:
# while lt[n] is not None:
# yield lt[n], n
# n = n + 1
#
# ll = [1]
# i = 1
# while i <= n:
# if i==n:
# ll.append(1)
# i = i + 1
# else:
# j= lt[n-1][i-1] + lt[n-1][i]
# ll.append(j)
# i = i + 1
# lt.append(ll)
#
#
# tri = triangles()
# print(next(tri))
# print(next(tri))
# print(next(tri))
# print(next(tri))