forked from tongzm/ml-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode.txt
More file actions
103 lines (70 loc) · 2.55 KB
/
code.txt
File metadata and controls
103 lines (70 loc) · 2.55 KB
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
#去重
df = df.drop_duplicates().reset_index(drop=True)
#删除某一列
df2=df2.drop(cols,axis=1)
#删除两行
df.drop(index=[0, 1])
#date转字符串
from datetime import datetime, date, time
d = date.fromisoformat('2018-09-22')
t = time.fromisoformat('16:28:22')
dt = datetime.fromisoformat('2018-09-22')
sdate = pd.to_datetime(ds).strftime('%Y-%m-%d')
st = "2019-01-20 00:00:00"
dt = datetime.datetime.strptime(st, '%Y-%m-%d %H:%M:%S')
st = "2019-01-20"
dt = datetime.datetime.strptime(st, '%Y-%m-%d')
start=pd.to_datetime('2017-01-01')
#修改类型
train['tf_status'] = t1['tf_status'].astype(np.int64)
#修改日期类型
df['ds'] = pd.to_datetime(df['ds'])
#修改字段名
df.rename(columns={'#studentid':'studentid'}, inplace = True)
#加年月
df['year']=df.datetime.apply(lambda x: x.year)
df['month'] = df.datetime.apply(lambda x: x.month)
df['year'] = df['year'].astype(np.int64)
df['month'] = df['month'].astype(np.int64)
#删除字段
df.drop(['#id'], axis=1, inplace=True)
#查看数据中顶部10%的数据
print(df.weeks.quantile(np.arange(.9,1,.01)))
#设置索引
df = df.set_index(['hetongdetailid'])
#判断空值
print("在 cat 列中总共有 %d 个空值." % df['cat'].isnull().sum())
print("在 review 列中总共有 %d 个空值." % df['review'].isnull().sum())
df[df.isnull().values==True]
df = df[pd.notnull(df['review'])]
#排序
df.sort_values(by="x1",ascending= False)
#模糊查询
df_remark_tf[df_remark_tf["content_method"].str.contains(keystring)]
#修改字段类型
df_appraise['deptid'] = df_appraise['deptid'].astype(np.int64)
#修改数据(https://blog.csdn.net/zhangchuang601/article/details/79583551)
df.loc[1,['name','age']] = ['bb',11]
df.iloc[1,2] = 19#修改某一无
df.loc[df[df.htid.isin(ids)].index,"y"]=1
#保存数据库
df.to_sql(name='predict',con=mysql_engine,if_exists = 'replace')
#生成日期
dt = datetime.datetime(year, month, 1)
#查看顶部10%数据分布
print(movie_rating_count['totalRatingCount'].quantile(np.arange(.9,1,.01)))
#-------plotly.express-------------------------
fig = px.line(df, x='date', y='y_true',
labels={'date':'日期', 'y_true':'话务量'},
markers=True)
fig.update_xaxes(tickformat = "%Y-%m-%d", hoverformat = "%Y-%m-%d")
fig.update_layout(title_text="热线部门日业务量趋势图", title_x=0.5)
fig.show()
----------------------------------
1、nohup command &
例如 nohup jupyter notebook &
2、找到进程PID(关闭在前面后台执行的进程的步骤,首先找到其进程PID)
ps -ef | grep xxxx
ps -ef 查看本机所有的进程;grep xxxx代表过滤找到条件xxxx的项目
3、kill掉进程
kill -9 具体的PID