Me_learn.py 46 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049
  1. import tkinter
  2. from tkinter.filedialog import askopenfilename,asksaveasfilename
  3. import tkinter.messagebox
  4. import Learn
  5. import webbrowser
  6. import os
  7. from tkinter.scrolledtext import ScrolledText
  8. import chardet
  9. #数据清洗
  10. Clean_Text='''#输入你的数据清洗执行代码
  11. Done_Row=[] #输入操作的行号
  12. Done_Column=[] #输入操作的列号
  13. axis=True #True-操作行,False-操作列
  14. name='' #方法代号
  15. def check(data,row,column,get,R,C): #检查方法
  16. return True
  17. def done(data,row,column,get,R,C): #应用修正方法
  18. return DEL
  19. '''
  20. Clean_Help='''
  21. 使用Python代码进行数据清洗
  22. 1)代码结构
  23. Done_Row=[] 代码用来检测的数据的列号
  24. Done_Column=[] 代码用来检测的数据的行号
  25. 不在以上指定范围内的数据将不会被检测,若为空则整个表格检测
  26. axis 执行删除方法时删除行或者列
  27. name 方法代号
  28. check 检查方法
  29. 输入:当前的值(输入的是一个值而不是一行(列)或整个列表)
  30. 输入:row和column当前值来自的行号(row)和列号(column)
  31. 输入:get当前检查的所有数据:类型是表格
  32. 输入:R和C当前值所来自的行和列的所有数据:类型是一维表格
  33. 输出:输出布尔为True代表该值可以使用,输出布尔为假表示该值不可使用
  34. done 不可使用的数值改造方法
  35. 输入:内容同上
  36. 输出:改造值或者DEL
  37. DEL:代表删除改值所在的行(axis = True)或列(axis = False)
  38. 2)扩展
  39. 默认:pd-pandas,re-re[正则表达式],Sheet-包含所有表格,用Sheet['name']访问名字为name的表格(注意引号别漏了)
  40. 支持:可以使用import导入语句,支持python语法
  41. '''
  42. Args_Help='''
  43. 输入python变量赋值代码:渲染设置
  44. title #设置标题:str
  45. vice_title #设置副标题:str
  46. show_Legend #是否显示图例:bool
  47. show_Visual_mapping #是否使用视觉映射:bool
  48. is_color_Visual_mapping #是否为颜色视觉映射:bool[否则为大小视觉映射]
  49. min_Visual_mapping #映射的最小值
  50. max_Visual_mapping #映射的最大值
  51. ......(我太懒了,设置太多不想写了)
  52. '''
  53. def DTYPE():
  54. global Dtype_Column, Dtype_Input, Dtype_Wrong, Dtype_Func,ML
  55. type_ = bool(Dtype_Func.get())
  56. name = get_Name()
  57. column_list = Dtype_Column.get().split(',')
  58. if column_list == ['']:column_list = []
  59. dtype = Dtype_Input.get()
  60. wrong = Dtype_Wrong.get()
  61. if wrong != 'ignore':wrong = 'coerce'
  62. if type_:#软转换
  63. ML.Reasonable_Type(name,column_list,dtype,wrong)
  64. else:
  65. ML.as_Type(name,column_list,dtype,wrong)
  66. Updat_BOX()
  67. def Import_c():#导入绘制方法
  68. global Done_Func
  69. Dic = askopenfilename(title='打开Python脚本',filetypes=[("Python", ".py"),("TXT", ".txt")])
  70. with open(Dic) as f:
  71. get = f.read()
  72. Render_ToHTML(ML.Import_c(get), '自定义图')
  73. def get_ARGS():#获取画图的args
  74. global Args_Input
  75. return Args_Input.get('0.0',tkinter.END)
  76. def Draw():
  77. global R_Dic,R_BOX
  78. Dic = asksaveasfilename(title='选择渲染保存地址',filetypes=[("HTML", ".html")]) + '.html'
  79. if Dic == '.html':return False
  80. webbrowser.open(ML.Draw_Page(get_ARGS(),Dic))
  81. Update_R_BOX()
  82. def Draw_One():
  83. global R_Dic, R_BOX
  84. Dic = asksaveasfilename(title='选择渲染保存地址', filetypes=[("HTML", ".html")]) + '.html'
  85. if Dic == '.html': return False
  86. list(R_Dic.values())[R_BOX.curselection()[0]].render(Dic)
  87. webbrowser.open(Dic)
  88. Update_R_BOX()
  89. def Del_R_BOX():
  90. global R_Dic,R_BOX,ML
  91. key = list(R_Dic.keys())[R_BOX.curselection()[0]]
  92. ML.Delete_RDic(key)
  93. Update_R_BOX()
  94. def Update_R_BOX():
  95. global R_Dic,R_BOX,ML
  96. R_Dic = ML.retunr_RDic()
  97. R_BOX.delete(0, tkinter.END)
  98. R_BOX.insert(tkinter.END, *R_Dic.keys())
  99. def Render_ToHTML(c,name):
  100. global R_Dic,Draw_asWell
  101. if bool(Draw_asWell.get()):
  102. c.render(f'{PATH}\\{name}.html')
  103. Update_R_BOX()
  104. def to_Gauge():
  105. global ML
  106. name = get_Name()
  107. Render_ToHTML(ML.to_Gauge(name,get_ARGS()),'仪表图')
  108. def to_Liquid():
  109. global ML
  110. name = get_Name()
  111. Render_ToHTML(ML.to_Liquid(name,get_ARGS()),'水球图')
  112. def to_Line3D():
  113. global ML
  114. name = get_Name()
  115. Render_ToHTML(ML.to_Line3D(name,get_ARGS()),'3D折线图')
  116. def to_Scatter3D():
  117. global ML
  118. name = get_Name()
  119. Render_ToHTML(ML.to_Scatter3D(name,get_ARGS()),'3D散点图')
  120. def to_Bar3d():
  121. global ML
  122. name = get_Name()
  123. Render_ToHTML(ML.to_Bar3d(name,get_ARGS()),'3D柱状图')
  124. def to_WordCloud():
  125. global ML
  126. name = get_Name()
  127. Render_ToHTML(ML.to_WordCloud(name,get_ARGS()),'词云图')
  128. def to_Radar():
  129. global ML
  130. name = get_Name()
  131. Render_ToHTML(ML.to_Radar(name,get_ARGS()),'雷达图')
  132. def to_Polar():
  133. global ML
  134. name = get_Name()
  135. Render_ToHTML(ML.to_Polar(name,get_ARGS()),'极坐标图')
  136. def to_Pie():
  137. global ML
  138. name = get_Name()
  139. Render_ToHTML(ML.to_Pie(name,get_ARGS()),'饼图')
  140. def to_Parallel():
  141. global ML
  142. name = get_Name()
  143. Render_ToHTML(ML.to_Parallel(name,get_ARGS()),'多轴图')
  144. def to_Graph():
  145. global ML
  146. name = get_Name()
  147. Render_ToHTML(ML.to_Graph(name,get_ARGS()),'关系图')
  148. def to_Funnel():
  149. global ML
  150. name = get_Name()
  151. Render_ToHTML(ML.to_Funnel(name,get_ARGS()),'漏斗图')
  152. def to_HeatMap():
  153. global ML
  154. name = get_Name()
  155. Render_ToHTML(ML.to_HeatMap(name,get_ARGS()),'热力图')
  156. def to_Boxpolt():
  157. global ML
  158. name = get_Name()
  159. Render_ToHTML(ML.to_Boxpolt(name,get_ARGS()),'箱形图')
  160. def to_Pictorialbar():
  161. global ML
  162. name = get_Name()
  163. Render_ToHTML(ML.to_Pictorialbar(name,get_ARGS()),'象形柱状图')
  164. def to_Scatter():
  165. global ML
  166. name = get_Name()
  167. Render_ToHTML(ML.to_Scatter(name,get_ARGS()),'散点图')
  168. def to_Line():
  169. global ML
  170. name = get_Name()
  171. Render_ToHTML(ML.to_Line(name,get_ARGS()),'折线图')
  172. def to_Bar():
  173. global ML
  174. name = get_Name()
  175. Render_ToHTML(ML.to_Bar(name,get_ARGS()),'柱状图')
  176. def Show_Help():
  177. tkinter.messagebox.showinfo('帮助字典',Clean_Help)
  178. def Open_Python():
  179. global Done_Func
  180. Dic = askopenfilename(title='打开Python脚本',filetypes=[("Python", ".py"),("TXT", ".txt")])
  181. with open(Dic) as f:
  182. get = f.read()
  183. Done_Func.delete('0.0', tkinter.END)
  184. Done_Func.insert('0.0', get)
  185. def get_InsertClean_Text():
  186. global Done_Func,Clean_Text
  187. Done_Func.delete('0.0',tkinter.END)
  188. Done_Func.insert('0.0',Clean_Text)
  189. def get_CleanEXP():
  190. global ML,Clean_List,Done_CleanBox,Done_Func
  191. name = Clean_List[Done_CleanBox.curselection()[0]]
  192. get = ML.Return_CleanExp(name)
  193. Done_Func.delete('0.0',tkinter.END)
  194. Done_Func.insert('0.0',get)
  195. def Tra_Clean():
  196. global ML
  197. ML.Tra_Clean()
  198. Updat_BOX()
  199. def Done_Clean():
  200. global ML
  201. name = get_Name()
  202. Data = ML.Done_CleanFunc(name)
  203. title = f'CoTan机器学习 表格:{name}.数据清洗'
  204. Creat_TextSheet(Data, title)
  205. Updat_BOX()
  206. def Del_Clean():
  207. global ML,Clean_List,Done_CleanBox
  208. name = Clean_List[Done_CleanBox.curselection()[0]]
  209. ML.Delete_CleanFunc(name)
  210. Update_Clean()
  211. def Update_Clean():
  212. global ML,Done_CleanBox,Clean_List
  213. Clean_List = ML.Return_CleanFunc()
  214. Done_CleanBox.delete(0, tkinter.END)
  215. Done_CleanBox.insert(tkinter.END, *Clean_List)
  216. def Add_Clean():
  217. global ML,Done_CleanBox,Done_Func
  218. Exp = Done_Func.get('0.0',tkinter.END)
  219. print(Exp)
  220. ML.Add_CleanFunc(Exp)
  221. Update_Clean()
  222. def Done_NaN():
  223. global Drop_Column
  224. name = get_Name()
  225. Data = ML.Dropna(name,True)
  226. title = f'CoTan机器学习 表格:{name}.NaN'
  227. Creat_TextSheet(Data, title)
  228. Updat_BOX()
  229. def is_Na():
  230. global Bool_E
  231. name = get_Name()
  232. Data = ML.is_Na(name)
  233. title = f'CoTan机器学习 表格:{name}.NaN'
  234. Creat_TextSheet(Data, title)
  235. Updat_BOX()
  236. def Make_BoolSheet():
  237. global Bool_E
  238. Bool_Exp = Bool_E.get()
  239. name = get_Name()
  240. Data = ML.Done_Bool(name,Bool_Exp,True)
  241. print(Data)
  242. title = f'CoTan机器学习 表格:{name} 布尔化'
  243. Creat_TextSheet(Data, title)
  244. Updat_BOX()
  245. def Del_Data():
  246. global Slice_new, Column_clist, Row_clist
  247. Column = Column_clist[0].get().replace(' ','').split(',')
  248. Row = Row_clist[0].get().replace(' ', '').split(',')
  249. new = bool(Slice_new.get())
  250. name = get_Name()
  251. try:
  252. Data = ML.Delete(name,Column,Row,new)
  253. except:
  254. Data = 'None 你的操作不被允许'
  255. title = f'CoTan机器学习 表格:{name}'
  256. Creat_TextSheet(Data, title)
  257. Updat_BOX()
  258. def __get_clist(n,t=str):
  259. a = []
  260. for i in n:
  261. b = i.get().replace(' ','')
  262. if b == '':a.append(None)
  263. else:
  264. try:a.append(t(b))
  265. except:a.append(None)
  266. if a[0] != None and a[1] == None:
  267. a[1] = a[0]+1
  268. a[2] = None
  269. return a
  270. def Slice_Data():
  271. global Slice_new, Column_Type, Row_Type, Column_clist, Row_clist
  272. CT = Column_Type.get()
  273. U = True
  274. if CT == 0:#输入的列号
  275. Column = slice(*__get_clist(Column_clist,int))
  276. elif CT == 1:
  277. U = False
  278. Column = slice(*__get_clist(Column_clist, str))
  279. else:
  280. get = Column_clist[0].get().replace(' ','').split(',')
  281. Column = []
  282. for i in get:
  283. try:Column.append(int(i))
  284. except:pass
  285. RT = Row_Type.get()
  286. if RT == 0: # 输入的列号
  287. Row = slice(*__get_clist(Row_clist, int))
  288. elif RT == 1:
  289. Row = slice(*__get_clist(Row_clist, str))
  290. else:
  291. get = Row_clist[0].get().replace(' ', '').split(',')
  292. Row = []
  293. for i in get:
  294. try:
  295. Row.append(int(i))
  296. except:
  297. pass
  298. new = bool(Slice_new.get())
  299. name = get_Name()
  300. try:
  301. Data = ML.get_Clice(name,Column,Row,U,new)
  302. except:
  303. Data = 'None 你的操作不被允许'
  304. title = f'CoTan机器学习 表格:{name}'
  305. Creat_TextSheet(Data, title)
  306. Updat_BOX()
  307. def Stored_Value():
  308. global ML,Stored_List
  309. name = get_Name()
  310. new = bool(Ascending_New.get())
  311. Data = ML.Stored_Valuse(name, Stored_List,new)
  312. title = f'CoTan机器学习 表格:{name}.Stored'
  313. Creat_TextSheet(Data, title)
  314. Updat_BOX()
  315. def Tra_Stored_Value():
  316. global Stored_List, Stored_BOX
  317. Stored_List = []
  318. Update_Stored()
  319. def Delete_Stored_Value():
  320. global Stored_List,Stored_BOX,Ascending_Type
  321. del Stored_List[Stored_BOX.curselection()[0]]
  322. Update_Stored()
  323. def add_Stored_Value():#按基准列排行
  324. global ML,Stored_List,Sort_By,Ascending_Type
  325. try:
  326. a = not bool(Ascending_Type.get())
  327. value = int(Sort_By.get())
  328. Stored_List.append((value,a))
  329. except:pass
  330. Update_Stored()
  331. def Update_Stored():
  332. global Stored_List,Stored_BOX
  333. re = []
  334. d = {True:'正序',False:'倒叙'}
  335. for i in Stored_List:
  336. re.append(f"列号:{i[0]},排序方式{d[i[1]]}")
  337. Stored_BOX.delete(0,tkinter.END)
  338. Stored_BOX.insert(tkinter.END,*re)
  339. def Stored_Column():#行
  340. global ML
  341. name = get_Name()
  342. a = not bool(Ascending_Type.get())
  343. new = bool(Ascending_New.get())
  344. Data = ML.Sorted(name,False,new,a)
  345. title = f'CoTan机器学习 表格:{name}.Stored by Column'
  346. Creat_TextSheet(Data, title)
  347. Updat_BOX()
  348. def Stored_Row():#行
  349. global ML
  350. name = get_Name()
  351. new = bool(Ascending_New.get())
  352. a = not bool(Ascending_Type.get())
  353. Data = ML.Sorted(name,True,new,a)
  354. title = f'CoTan机器学习 表格:{name}.Stored by Row'
  355. Creat_TextSheet(Data, title)
  356. Updat_BOX()
  357. def T():
  358. global ML
  359. name = get_Name()
  360. new = bool(Ascending_New.get())
  361. Data = ML.T(name,new)
  362. title = f'CoTan机器学习 表格:{name}.T'
  363. Creat_TextSheet(Data, title)
  364. Updat_BOX()
  365. def Show_Des():
  366. global PATH,top
  367. if not tkinter.messagebox.askokcancel('提示', f'是否统计数据,大量的数据需要耗费一定的时间(确定后,系统会在后台统计)'):return False
  368. Dic = f'{PATH}/$Show_Des_Sheet.html'
  369. try:
  370. name = get_Name()
  371. if name == None:raise Exception
  372. ML.to_Report(name,Dic)
  373. webbrowser.open(Dic)
  374. except:
  375. pass
  376. def Show_describe():
  377. global ML,Des_Bool
  378. Des = bool(Des_Bool.get())
  379. name = get_Name()
  380. title = f'CoTan机器学习 表格:{name}_describe'
  381. Data = str(ML.Describe(name,Des))
  382. Creat_TextSheet(Data, title)
  383. Updat_BOX()
  384. def Write_Sheet():
  385. global ML,top
  386. name = get_Name()
  387. title = f'CoTan机器学习 表格:{name}'
  388. Data = str(ML.get_Sheet(name))
  389. Creat_TextSheet(Data,title)
  390. def Creat_TextSheet(data,name):
  391. global bg,ft1
  392. new_top = tkinter.Toplevel(bg=bg)
  393. new_top.title(name)
  394. new_top.geometry('+10+10')#设置所在位置
  395. text = ScrolledText(new_top,font=ft1,height=50)
  396. text.pack(fill=tkinter.BOTH)
  397. text.insert('0.0',data)
  398. text.config(state=tkinter.DISABLED)
  399. new_top.resizable(width=False, height=False)
  400. def get_Column():#列名(横行竖列,列名是上面的)
  401. global ML
  402. name = get_Name()
  403. Updat_IndexBOX(ML.get_Column(name))
  404. def get_Index():#行名(横行竖列,行名左)
  405. global ML
  406. name = get_Name()
  407. Updat_IndexBOX(ML.get_Index(name))
  408. def Updat_IndexBOX(get_Index):
  409. global top,Index_BOX
  410. Index_BOX.delete(0,tkinter.END)
  411. Index_BOX.insert(tkinter.END, *get_Index)
  412. def Show():
  413. global PATH,to_HTML_Type
  414. Dic = f'{PATH}/$Show_Sheet.html'
  415. try:
  416. name = get_Name()
  417. if name == None:raise Exception
  418. ML.to_Html(name,Dic,to_HTML_Type.get())
  419. webbrowser.open(Dic)
  420. except:
  421. raise
  422. def Add_CSV():
  423. global top,Seq_Input,Code_Input,str_must,Index_must
  424. Dic = askopenfilename(title='选择载入的CSV',filetypes=[("CSV", ".csv")])
  425. Seq = Seq_Input.get()
  426. Codeing = Code_Input.get()
  427. str_ = bool(str_must.get())
  428. Index = bool(Index_must.get())
  429. if Codeing == '':
  430. with open(Dic, 'rb') as f:
  431. Codeing = chardet.detect(f.read())['encoding']
  432. print(Codeing)
  433. if Seq == '':Seq = ','
  434. ML.Add_CSV(Dic,'',Seq,Codeing,str_,Index)
  435. Updat_BOX()
  436. def Add_Python():
  437. global top,Seq_Input,Code_Input,str_must,Index_must
  438. Dic = askopenfilename(title='选择载入的py',filetypes=[("Python", ".py"),("Txt", ".txt")])
  439. with open(Dic,'r') as f:
  440. ML.Add_Python(f.read(),'')
  441. Updat_BOX()
  442. def Add_Html():
  443. global top,Seq_Input,Code_Input,str_must,Index_must
  444. Dic = askopenfilename(title='选择载入的Html',filetypes=[("CSV", ".csv")])
  445. Codeing = Code_Input.get()
  446. str_ = bool(str_must.get())
  447. Index = bool(Index_must.get())
  448. if Codeing == '':
  449. with open(Dic, 'rb') as f:
  450. Codeing = chardet.detect(f.read())['encoding']
  451. print(Codeing)
  452. ML.Add_Html(Dic,'',Codeing,str_,Index)
  453. Updat_BOX()
  454. def get_Name():#获得名字统一接口
  455. global Form_List
  456. try:
  457. return Form_List[Form_BOX.curselection()[0]]
  458. except:
  459. try:
  460. return Form_List[0]
  461. except:
  462. return None
  463. def Updat_BOX():
  464. global top,Form_BOX,Form_List
  465. Form_List = ML.get_FormList()
  466. Form_BOX.delete(0,tkinter.END)
  467. Form_BOX.insert(tkinter.END, *Form_List)
  468. def Machine_learning():
  469. global top,ML,Form_List,PATH,bg,ft1,Stored_List,Clean_List,R_Dic
  470. R_Dic = {}#保存了画图的List
  471. PATH = os.getcwd()
  472. Form_List = []
  473. ML = Learn.Form()
  474. top = tkinter.Tk()
  475. bg = '#FFFAFA'#主颜色
  476. bbg = '#FFFAFA'#按钮颜色
  477. fg = '#000000'#文字颜色
  478. top["bg"] = bg
  479. FONT = ('黑体', 11)#设置字体
  480. ft1 = ('黑体',13)
  481. top.title('CoTan机器学习')
  482. top.resizable(width=False, height=False)
  483. top.geometry('+10+10')#设置所在位置
  484. width_B = 13#标准宽度
  485. height_B=2
  486. a_y = 0
  487. a_x = 0
  488. Stored_List = []
  489. Clean_List = []
  490. tkinter.Button(top, bg=bbg, fg=fg, text='导入CSV',command=Add_CSV, font=FONT, width=width_B,
  491. height=height_B).grid(column=a_x, row=a_y, sticky=tkinter.E + tkinter.W + tkinter.W+tkinter.S + tkinter.N)
  492. tkinter.Button(top, bg=bbg, fg=fg, text='导入Py',command=Add_Python, font=FONT, width=width_B,
  493. height=height_B).grid(column=a_x+1, row=a_y, sticky=tkinter.E + tkinter.W + tkinter.W+tkinter.S + tkinter.N)
  494. tkinter.Button(top, bg=bbg, fg=fg, text='导入HTML',command=Add_Html, font=FONT, width=width_B,
  495. height=height_B).grid(column=a_x+2, row=a_y, sticky=tkinter.E + tkinter.W + tkinter.W+tkinter.S + tkinter.N)
  496. a_y += 1
  497. tkinter.Button(top, bg=bbg, fg=fg, text='删除表格', font=FONT, width=width_B,
  498. height=height_B).grid(column=a_x, row=a_y, sticky=tkinter.E + tkinter.W + tkinter.W+tkinter.S + tkinter.N)
  499. tkinter.Button(top, bg=bbg, fg=fg, text='查看表格',command=Show, font=FONT, width=width_B,
  500. height=height_B).grid(column=a_x+1, row=a_y, sticky=tkinter.E + tkinter.W + tkinter.W+tkinter.S + tkinter.N)
  501. tkinter.Button(top, bg=bbg, fg=fg, text='清空表格', font=FONT, width=width_B,
  502. height=height_B).grid(column=a_x+2, row=a_y, sticky=tkinter.E + tkinter.W + tkinter.W+tkinter.S + tkinter.N)
  503. global Form_BOX,Index_BOX,Column_BOX,to_HTML_Type,Seq_Input,Code_Input,str_must,Index_must
  504. a_y += 1
  505. to_HTML_Type = tkinter.IntVar()#正,负,0
  506. lable = ['选项卡型','可移动型','自适应型']#复选框
  507. for i in range(3):
  508. tkinter.Radiobutton(top,bg = bg,fg = fg,activebackground=bg,activeforeground=fg,selectcolor=bg,text=lable[i], variable=to_HTML_Type,
  509. value=i).grid(column=a_x+i, row=a_y, sticky=tkinter.W)
  510. str_must = tkinter.IntVar()
  511. Index_must = tkinter.IntVar()
  512. a_y += 1
  513. tkinter.Label(top, text='编码方式:', bg=bg, fg=fg, font=FONT, width=width_B, height=height_B).grid(column=a_x,row=a_y) # 设置说明
  514. Code_Input = tkinter.Entry(top, width=width_B)
  515. Code_Input.grid(column=a_x + 1, row=a_y, sticky=tkinter.E + tkinter.W)
  516. buttom = tkinter.Checkbutton(top, bg=bg, fg=fg, activebackground=bg, activeforeground=fg, selectcolor=bg, text='字符串类型',
  517. variable=str_must)
  518. buttom.select()
  519. buttom.grid(column=a_x + 2, row=a_y, sticky=tkinter.W)
  520. a_y += 1
  521. tkinter.Label(top, text='CSV分隔符:', bg=bg, fg=fg, font=FONT, width=width_B, height=height_B).grid(column=a_x,row=a_y) # 设置说明
  522. Seq_Input = tkinter.Entry(top, width=width_B)
  523. Seq_Input.grid(column=a_x + 1, row=a_y, sticky=tkinter.E + tkinter.W)
  524. tkinter.Checkbutton(top, bg=bg, fg=fg, activebackground=bg, activeforeground=fg, selectcolor=bg, text='重置列名',
  525. variable=Index_must).grid(column=a_x + 2, row=a_y, sticky=tkinter.W)
  526. a_y += 1
  527. Form_BOX = tkinter.Listbox(top, width=width_B * 3,height = height_B*5) # 显示符号
  528. Form_BOX.grid(column=a_x, row=a_y, columnspan=3, rowspan=5,sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N)
  529. a_y += 5
  530. tkinter.Button(top, bg=bbg, fg=fg, text='查看行名',command=get_Index, font=FONT, width=width_B,
  531. height=height_B).grid(column=a_x, row=a_y, sticky=tkinter.E + tkinter.W + tkinter.W+tkinter.S + tkinter.N)
  532. tkinter.Button(top, bg=bbg, fg=fg, text='查看列名',command=get_Column, font=FONT, width=width_B,
  533. height=height_B).grid(column=a_x+1, row=a_y, sticky=tkinter.E + tkinter.W + tkinter.W+tkinter.S + tkinter.N)
  534. tkinter.Button(top, bg=bbg, fg=fg, text='显示表格',command=Write_Sheet, font=FONT, width=width_B,
  535. height=height_B).grid(column=a_x+2, row=a_y, sticky=tkinter.E + tkinter.W + tkinter.W+tkinter.S + tkinter.N)
  536. global Max_Row,Max_Column
  537. a_y += 1
  538. tkinter.Label(top, text='最大显示行数:', bg=bg, fg=fg, font=FONT, width=width_B, height=height_B).grid(column=a_x,row=a_y) # 设置说明
  539. Max_Row = tkinter.Entry(top, width=width_B * 2)
  540. Max_Row.grid(column=a_x + 1, row=a_y, columnspan=2, sticky=tkinter.E + tkinter.W)
  541. a_y += 1
  542. tkinter.Label(top, text='最大显示列数:', bg=bg, fg=fg, font=FONT, width=width_B, height=height_B).grid(column=a_x,row=a_y) # 设置说明
  543. Max_Column = tkinter.Entry(top, width=width_B * 2)
  544. Max_Column.grid(column=a_x + 1, row=a_y, columnspan=2, sticky=tkinter.E + tkinter.W)
  545. #Row与Column Row是横行,tkinter布局中Row变大,表示所在行数变大,向下移动如:
  546. # 1,2,3,4,5,6
  547. # 7,8,9,a,b,c
  548. # 其中数字1-6是第一行,1-c是第二行,第二行在第一行下面,row变大向下移动(Row是横向行而不是横向移动) to 搞不清楚横行竖列的人
  549. a_y += 1
  550. Index_BOX = tkinter.Listbox(top, width=width_B * 3,height = height_B*3) # 显示符号
  551. Index_BOX.grid(column=a_x, row=a_y, columnspan=3, rowspan=3,sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N)
  552. global Des_Bool
  553. a_y += 3
  554. tkinter.Button(top, bg=bbg, fg=fg, text='查看数据分析',command=Show_Des, font=FONT, width=width_B,
  555. height=height_B).grid(column=a_x, row=a_y, sticky=tkinter.E + tkinter.W + tkinter.W+tkinter.S + tkinter.N)
  556. tkinter.Button(top, bg=bbg, fg=fg, text='简单数据统计',command=Show_describe, font=FONT, width=width_B,
  557. height=height_B).grid(column=a_x+1, row=a_y, sticky=tkinter.E + tkinter.W + tkinter.W+tkinter.S + tkinter.N)
  558. Des_Bool = tkinter.IntVar()#是否启用
  559. tkinter.Checkbutton(top, bg=bg, fg=fg, activebackground=bg, activeforeground=fg, selectcolor=bg, text='生成统计表格',
  560. variable=Des_Bool).grid(column=a_x + 2, row=a_y, sticky=tkinter.W)
  561. a_y += 1
  562. tkinter.Label(top, text='【排序操作】', bg=bg, fg=fg, font=FONT, width=width_B*3, height=height_B).grid(column=a_x,
  563. columnspan=3,row=a_y) # 设置说明
  564. a_y += 1
  565. tkinter.Button(top, bg=bbg, fg=fg, text='表格转置', command=T, font=FONT, width=width_B,
  566. height=height_B).grid(column=a_x, row=a_y, sticky=tkinter.E + tkinter.W + tkinter.W+tkinter.S + tkinter.N)
  567. tkinter.Button(top, bg=bbg, fg=fg, text='按行名排序', command=Stored_Row, font=FONT, width=width_B,
  568. height=height_B).grid(column=a_x + 1, row=a_y, sticky=tkinter.E + tkinter.W + tkinter.W+tkinter.S + tkinter.N)
  569. tkinter.Button(top, bg=bbg, fg=fg, text='按列名排序', command=Stored_Column, font=FONT, width=width_B,
  570. height=height_B).grid(column=a_x+2, row=a_y, sticky=tkinter.E + tkinter.W + tkinter.W+tkinter.S + tkinter.N)
  571. global Sort_By,Ascending_Type,Ascending_New,Stored_BOX
  572. a_y += 1
  573. tkinter.Label(top, text='基准列(列号):', bg=bg, fg=fg, font=FONT, width=width_B, height=height_B).grid(column=a_x,row=a_y) # 设置说明
  574. Sort_By = tkinter.Entry(top, width=width_B+2)
  575. Sort_By.grid(column=a_x + 1, row=a_y, sticky=tkinter.W)
  576. tkinter.Button(top, bg=bbg, fg=fg, text='按数据排序', command=Stored_Value, font=FONT, width=width_B,
  577. height=height_B).grid(column=a_x + 2, row=a_y, sticky=tkinter.E + tkinter.W + tkinter.W+tkinter.S + tkinter.N)
  578. a_y += 1
  579. Ascending_Type = tkinter.IntVar()
  580. Ascending_New = tkinter.IntVar()
  581. lable = ['正序排列','倒序排列']#复选框
  582. for i in range(2):
  583. tkinter.Radiobutton(top,bg = bg,fg = fg,activebackground=bg,activeforeground=fg,selectcolor=bg,text=lable[i], variable=Ascending_Type, value=i).\
  584. grid(column=a_x+i, row=a_y, sticky=tkinter.W)
  585. tkinter.Checkbutton(top, bg=bg, fg=fg, activebackground=bg, activeforeground=fg, selectcolor=bg, text='生成新表格',
  586. variable=Ascending_New).grid(column=a_x + 2, row=a_y, sticky=tkinter.W)
  587. a_y += 1
  588. Stored_BOX = tkinter.Listbox(top, width=width_B * 3,height = height_B*3) # 显示符号
  589. Stored_BOX.grid(column=a_x, row=a_y, columnspan=3, rowspan=3,sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N)
  590. a_y += 3
  591. tkinter.Button(top, bg=bbg, fg=fg, text='添加基准', command=add_Stored_Value, font=FONT, width=width_B,
  592. height=height_B).grid(column=a_x, row=a_y, sticky=tkinter.E + tkinter.W + tkinter.W+tkinter.S + tkinter.N)
  593. tkinter.Button(top, bg=bbg, fg=fg, text='删除基准', command=Delete_Stored_Value, font=FONT, width=width_B,
  594. height=height_B).grid(column=a_x + 1, row=a_y, sticky=tkinter.E + tkinter.W + tkinter.W+tkinter.S + tkinter.N)
  595. tkinter.Button(top, bg=bbg, fg=fg, text='清空基准', command=Tra_Stored_Value, font=FONT, width=width_B,
  596. height=height_B).grid(column=a_x+2, row=a_y, sticky=tkinter.E + tkinter.W + tkinter.W+tkinter.S + tkinter.N)
  597. a_x += 3
  598. tkinter.Label(top, text='', bg=bg, fg=fg, font=FONT, width=1).grid(column=a_x,row=a_y) # 设置说明
  599. a_x += 1
  600. a_y = 0
  601. tkinter.Label(top, text='【数据清洗】', bg=bg, fg=fg, font=FONT, width=width_B*3, height=height_B).grid(column=a_x,
  602. columnspan=3,row=a_y, sticky=tkinter.E + tkinter.W + tkinter.W+tkinter.S + tkinter.N) # 设置说明
  603. global Slice_new,Column_Type,Row_Type,Column_clist,Row_clist
  604. Column_clist = []
  605. Row_clist = []
  606. label = ['启始(列号):','终止(列):','间隔(列):']
  607. for i in range(3):
  608. a_y += 1
  609. tkinter.Label(top, text=label[i], bg=bg, fg=fg, font=FONT, width=width_B, height=height_B).grid(column=a_x,row=a_y) # 设置说明
  610. Column_clist.append(tkinter.Entry(top, width=width_B * 2))
  611. Column_clist[-1].grid(column=a_x + 1, row=a_y,columnspan=2, sticky=tkinter.W+tkinter.E)
  612. label = ['启始(行号):', '终止(行):', '间隔(行):']
  613. for i in range(3):
  614. a_y += 1
  615. tkinter.Label(top, text=label[i], bg=bg, fg=fg, font=FONT, width=width_B, height=height_B).grid(column=a_x,row=a_y) # 设置说明
  616. Row_clist.append(tkinter.Entry(top, width=width_B * 2))
  617. Row_clist[-1].grid(column=a_x + 1, row=a_y,columnspan=2, sticky=tkinter.W+tkinter.E)
  618. a_y += 1
  619. Column_Type = tkinter.IntVar()
  620. lable = ['根据列号','根据列名','输入列号']#复选框
  621. for i in range(3):
  622. tkinter.Radiobutton(top,bg = bg,fg = fg,activebackground=bg,activeforeground=fg,selectcolor=bg,text=lable[i], variable=Column_Type, value=i).\
  623. grid(column=a_x+i, row=a_y, sticky=tkinter.W)
  624. a_y += 1
  625. Row_Type = tkinter.IntVar()
  626. lable = ['根据行号','根据行名','输入行号']#复选框
  627. for i in range(3):
  628. tkinter.Radiobutton(top,bg = bg,fg = fg,activebackground=bg,activeforeground=fg,selectcolor=bg,text=lable[i], variable=Row_Type, value=i).\
  629. grid(column=a_x+i, row=a_y, sticky=tkinter.W)
  630. a_y += 1
  631. Slice_new = tkinter.IntVar()
  632. tkinter.Button(top, bg=bbg, fg=fg, text='切片选定', command=Slice_Data, font=FONT, width=width_B,
  633. height=height_B).grid(column=a_x, row=a_y, sticky=tkinter.E + tkinter.W + tkinter.W+tkinter.S + tkinter.N)
  634. tkinter.Button(top, bg=bbg, fg=fg, text='删除选定', command=Del_Data, font=FONT, width=width_B,
  635. height=height_B).grid(column=a_x + 1, row=a_y, sticky=tkinter.E + tkinter.W + tkinter.W+tkinter.S + tkinter.N)
  636. tkinter.Checkbutton(top, bg=bg, fg=fg, activebackground=bg, activeforeground=fg, selectcolor=bg, text='生成新表格',
  637. variable=Slice_new).grid(column=a_x + 2, row=a_y, sticky=tkinter.W)
  638. global Bool_E,Drop_Column
  639. a_y += 1
  640. tkinter.Label(top, text='布尔逻辑:', bg=bg, fg=fg, font=FONT, width=width_B, height=height_B).grid(column=a_x,
  641. row=a_y, sticky=tkinter.E + tkinter.W + tkinter.W+tkinter.S + tkinter.N) # 设置说明
  642. Bool_E = tkinter.Entry(top, width=width_B*2)
  643. Bool_E.grid(column=a_x + 1, row=a_y,columnspan=2, sticky=tkinter.W+tkinter.E)
  644. a_y += 1
  645. tkinter.Label(top, text='操作的列号:', bg=bg, fg=fg, font=FONT, width=width_B, height=height_B).grid(column=a_x,
  646. row=a_y, sticky=tkinter.E + tkinter.W + tkinter.W+tkinter.S + tkinter.N) # 设置说明
  647. Drop_Column = tkinter.Entry(top, width=width_B*2)
  648. Drop_Column.grid(column=a_x + 1, row=a_y,columnspan=2, sticky=tkinter.W+tkinter.E)
  649. a_y += 1
  650. tkinter.Button(top, bg=bbg, fg=fg, text='生成布尔表格', command=Make_BoolSheet, font=FONT, width=width_B,
  651. height=height_B).grid(column=a_x, row=a_y, sticky=tkinter.E + tkinter.W + tkinter.W+tkinter.S + tkinter.N)
  652. tkinter.Button(top, bg=bbg, fg=fg, text='查看空值', command=is_Na, font=FONT, width=width_B,
  653. height=height_B).grid(column=a_x+1, row=a_y, sticky=tkinter.E + tkinter.W + tkinter.W+tkinter.S + tkinter.N)
  654. tkinter.Button(top, bg=bbg, fg=fg, text='清洗空值(按行)', command=Done_NaN, font=FONT, width=width_B,
  655. height=height_B).grid(column=a_x + 2, row=a_y, sticky=tkinter.E + tkinter.W + tkinter.W+tkinter.S + tkinter.N)
  656. a_y += 1
  657. tkinter.Button(top, bg=bbg, fg=fg, text='添加执行方法', command=Add_Clean, font=FONT, width=width_B,
  658. height=height_B).grid(column=a_x, row=a_y, sticky=tkinter.E + tkinter.W + tkinter.W+tkinter.S + tkinter.N)
  659. tkinter.Button(top, bg=bbg, fg=fg, text='删除执行方法', command=Del_Clean, font=FONT, width=width_B,
  660. height=height_B).grid(column=a_x+1, row=a_y, sticky=tkinter.E + tkinter.W + tkinter.W+tkinter.S + tkinter.N)
  661. tkinter.Button(top, bg=bbg, fg=fg, text='执行数据清洗', command=Done_Clean, font=FONT, width=width_B,
  662. height=height_B).grid(column=a_x + 2, row=a_y, sticky=tkinter.E + tkinter.W + tkinter.W+tkinter.S + tkinter.N)
  663. global Done_CleanBox,Done_Func
  664. a_y += 1
  665. Done_CleanBox = tkinter.Listbox(top, width=width_B * 3, height=height_B * 2)
  666. Done_CleanBox.grid(column=a_x, row=a_y, columnspan=3, rowspan=2, sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N)
  667. a_y += 2
  668. tkinter.Button(top, bg=bbg, fg=fg, text='查看词典', command=Show_Help, font=FONT, width=width_B,
  669. height=height_B).grid(column=a_x, row=a_y, sticky=tkinter.E + tkinter.W + tkinter.W+tkinter.S + tkinter.N)
  670. tkinter.Button(top, bg=bbg, fg=fg, text='恢复显示', command=get_InsertClean_Text, font=FONT, width=width_B,
  671. height=height_B).grid(column=a_x+1, row=a_y, sticky=tkinter.E + tkinter.W + tkinter.W+tkinter.S + tkinter.N)
  672. tkinter.Button(top, bg=bbg, fg=fg, text='执行数据清洗', command=Done_Clean, font=FONT, width=width_B,
  673. height=height_B).grid(column=a_x + 2, row=a_y, sticky=tkinter.E + tkinter.W + tkinter.W+tkinter.S + tkinter.N)
  674. a_y += 1
  675. Done_Func = tkinter.Text(top,width=width_B*3,height=height_B*7)
  676. Done_Func.grid(column=a_x, row=a_y,columnspan=3,rowspan=7, sticky=tkinter.E + tkinter.W + tkinter.N + tkinter.S)
  677. Done_Func.insert('0.0',Clean_Text)
  678. a_y += 7
  679. tkinter.Button(top, bg=bbg, fg=fg, text='清空执行方法', command=Tra_Clean, font=FONT, width=width_B,
  680. height=height_B).grid(column=a_x, row=a_y, sticky=tkinter.E + tkinter.W+tkinter.S + tkinter.N)
  681. tkinter.Button(top, bg=bbg, fg=fg, text='查看执行方法', command=get_CleanEXP, font=FONT, width=width_B,
  682. height=height_B).grid(column=a_x+1, row=a_y, sticky=tkinter.E + tkinter.W + tkinter.W+tkinter.S + tkinter.N)
  683. tkinter.Button(top, bg=bbg, fg=fg, text='导入执行方法', command=Open_Python, font=FONT, width=width_B,
  684. height=height_B).grid(column=a_x + 2, row=a_y, sticky=tkinter.E + tkinter.W + tkinter.W+tkinter.S + tkinter.N)
  685. a_x += 3
  686. tkinter.Label(top, text='', bg=bg, fg=fg, font=FONT, width=1).grid(column=a_x,row=a_y) # 设置说明
  687. a_x += 1
  688. a_y = 0
  689. tkinter.Label(top, text='【数据画图】', bg=bg, fg=fg, font=FONT, width=width_B*3, height=height_B).grid(column=a_x,
  690. columnspan=3,row=a_y, sticky=tkinter.E + tkinter.W + tkinter.W+tkinter.S + tkinter.N) # 设置说明
  691. a_y += 1
  692. tkinter.Button(top, bg=bbg, fg=fg, text='生成柱状图', command=to_Bar, font=FONT, width=width_B,
  693. height=height_B).grid(column=a_x, row=a_y, sticky=tkinter.E + tkinter.W+tkinter.S + tkinter.N)
  694. tkinter.Button(top, bg=bbg, fg=fg, text='生成3D柱状图', command=to_Bar3d, font=FONT, width=width_B,
  695. height=height_B).grid(column=a_x+1, row=a_y, sticky=tkinter.E + tkinter.W + tkinter.W+tkinter.S + tkinter.N)
  696. tkinter.Button(top, bg=bbg, fg=fg, text='生成折线图', command=to_Line, font=FONT, width=width_B,
  697. height=height_B).grid(column=a_x+2, row=a_y, sticky=tkinter.E + tkinter.W + tkinter.W+tkinter.S + tkinter.N)
  698. a_y += 1
  699. tkinter.Button(top, bg=bbg, fg=fg, text='生成3D折线图', command=to_Line3D, font=FONT, width=width_B,
  700. height=height_B).grid(column=a_x, row=a_y, sticky=tkinter.E + tkinter.W+tkinter.S + tkinter.N)
  701. tkinter.Button(top, bg=bbg, fg=fg, text='生成象形柱状图', command=to_Pictorialbar, font=FONT, width=width_B,
  702. height=height_B).grid(column=a_x+1, row=a_y,columnspan=2, sticky=tkinter.E + tkinter.W+tkinter.S + tkinter.N)
  703. a_y += 1
  704. tkinter.Button(top, bg=bbg, fg=fg, text='生成散点图', command=to_Scatter, font=FONT, width=width_B,
  705. height=height_B).grid(column=a_x, row=a_y, sticky=tkinter.E + tkinter.W + tkinter.W+tkinter.S + tkinter.N)
  706. tkinter.Button(top, bg=bbg, fg=fg, text='生成3D散点图', command=to_Scatter3D, font=FONT, width=width_B,
  707. height=height_B).grid(column=a_x + 1, row=a_y, sticky=tkinter.E + tkinter.W + tkinter.W+tkinter.S + tkinter.N)
  708. tkinter.Button(top, bg=bbg, fg=fg, text='生成箱形图', command=to_Boxpolt, font=FONT, width=width_B,
  709. height=height_B).grid(column=a_x+2, row=a_y, sticky=tkinter.E + tkinter.W + tkinter.W+tkinter.S + tkinter.N)
  710. a_y += 1
  711. tkinter.Button(top, bg=bbg, fg=fg, text='生成漏斗图', command=to_Funnel, font=FONT, width=width_B,
  712. height=height_B).grid(column=a_x, row=a_y, sticky=tkinter.E + tkinter.W+tkinter.S + tkinter.N)
  713. tkinter.Button(top, bg=bbg, fg=fg, text='生成关系图', command=to_Graph, font=FONT, width=width_B,
  714. height=height_B).grid(column=a_x+1, row=a_y, sticky=tkinter.E + tkinter.W + tkinter.W+tkinter.S + tkinter.N)
  715. tkinter.Button(top, bg=bbg, fg=fg, text='生成饼图', command=to_Pie, font=FONT, width=width_B,
  716. height=height_B).grid(column=a_x+2, row=a_y, sticky=tkinter.E + tkinter.W+tkinter.S + tkinter.N)
  717. a_y += 1
  718. tkinter.Button(top, bg=bbg, fg=fg, text='生成多轴图', command=to_Parallel, font=FONT, width=width_B,
  719. height=height_B).grid(column=a_x, row=a_y, sticky=tkinter.E + tkinter.W + tkinter.W+tkinter.S + tkinter.N)
  720. tkinter.Button(top, bg=bbg, fg=fg, text='生成极坐标图', command=to_Polar, font=FONT, width=width_B,
  721. height=height_B).grid(column=a_x+1, row=a_y, sticky=tkinter.E + tkinter.W + tkinter.W+tkinter.S + tkinter.N)
  722. tkinter.Button(top, bg=bbg, fg=fg, text='生成雷达图', command=to_Radar, font=FONT, width=width_B,
  723. height=height_B).grid(column=a_x + 2, row=a_y, sticky=tkinter.E + tkinter.W + tkinter.W+tkinter.S + tkinter.N)
  724. a_y += 1
  725. tkinter.Button(top, bg=bbg, fg=fg, text='生成词云', command=to_WordCloud, font=FONT, width=width_B,
  726. height=height_B).grid(column=a_x, row=a_y,columnspan=2, sticky=tkinter.E + tkinter.W+tkinter.S + tkinter.N)
  727. tkinter.Button(top, bg=bbg, fg=fg, text='生成热力图', command=to_HeatMap, font=FONT, width=width_B,
  728. height=height_B).grid(column=a_x + 2, row=a_y, sticky=tkinter.E + tkinter.W + tkinter.W+tkinter.S + tkinter.N)
  729. a_y += 1
  730. tkinter.Button(top, bg=bbg, fg=fg, text='生成水球图', command=to_Liquid, font=FONT, width=width_B,
  731. height=height_B).grid(column=a_x, row=a_y,columnspan=2, sticky=tkinter.E + tkinter.W+tkinter.S + tkinter.N)
  732. tkinter.Button(top, bg=bbg, fg=fg, text='生成仪表图', command=to_Gauge, font=FONT, width=width_B,
  733. height=height_B).grid(column=a_x + 2, row=a_y, sticky=tkinter.E + tkinter.W + tkinter.W+tkinter.S + tkinter.N)
  734. a_y += 1
  735. tkinter.Button(top, bg=bbg, fg=fg, text='渲染HTML', command=Draw, font=FONT, width=width_B,
  736. height=height_B).grid(column=a_x, row=a_y, sticky=tkinter.E + tkinter.W + tkinter.W+tkinter.S + tkinter.N)
  737. tkinter.Button(top, bg=bbg, fg=fg, text='单独渲染HTML', command=Draw_One, font=FONT, width=width_B,
  738. height=height_B).grid(column=a_x+1, row=a_y, sticky=tkinter.E + tkinter.W + tkinter.W+tkinter.S + tkinter.N)
  739. tkinter.Button(top, bg=bbg, fg=fg, text='删除渲染', command=Del_R_BOX, font=FONT, width=width_B,
  740. height=height_B).grid(column=a_x+2, row=a_y, sticky=tkinter.E + tkinter.W + tkinter.W+tkinter.S + tkinter.N)
  741. a_y += 1
  742. global R_BOX,Args_Input
  743. R_BOX = tkinter.Listbox(top, width=width_B * 3, height=height_B * 3)
  744. R_BOX.grid(column=a_x, row=a_y, columnspan=3, rowspan=3, sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N)
  745. a_y += 3
  746. global Draw_asWell
  747. Draw_asWell = tkinter.IntVar()
  748. tkinter.Button(top, bg=bbg, fg=fg, text='清空渲染', command=Draw, font=FONT, width=width_B,
  749. height=height_B).grid(column=a_x, row=a_y, sticky=tkinter.E + tkinter.W + tkinter.W+tkinter.S + tkinter.N)
  750. tkinter.Button(top, bg=bbg, fg=fg, text='导入渲染', command=Draw, font=FONT, width=width_B,
  751. height=height_B).grid(column=a_x+1, row=a_y, sticky=tkinter.E + tkinter.W + tkinter.W+tkinter.S + tkinter.N)
  752. tkinter.Checkbutton(top, bg=bg, fg=fg, activebackground=bg, activeforeground=fg, selectcolor=bg, text='马上渲染',
  753. variable=Draw_asWell).grid(column=a_x + 2, row=a_y, sticky=tkinter.W)
  754. a_y += 1
  755. Args_Input = tkinter.Text(top,width=width_B*3,height=height_B*4)
  756. Args_Input.grid(column=a_x, row=a_y,columnspan=3,rowspan=6, sticky=tkinter.E + tkinter.W + tkinter.N + tkinter.S)
  757. a_y += 6
  758. tkinter.Button(top, bg=bbg, fg=fg, text='查看词典', font=FONT, width=width_B,
  759. height=height_B).grid(column=a_x, row=a_y, sticky=tkinter.E + tkinter.W + tkinter.W+tkinter.S + tkinter.N)
  760. tkinter.Button(top, bg=bbg, fg=fg, text='恢复显示', font=FONT, width=width_B,
  761. height=height_B).grid(column=a_x+1, row=a_y,columnspan = 2, sticky=tkinter.E + tkinter.W + tkinter.W+tkinter.S + tkinter.N)
  762. global Dtype_Column,Dtype_Input,Dtype_Wrong,Dtype_Func
  763. a_y += 1
  764. tkinter.Label(top, text='【数据类型管理】', bg=bg, fg=fg, font=FONT, width=width_B*3, height=height_B).grid(column=a_x,
  765. columnspan=3,row=a_y, sticky=tkinter.E + tkinter.W + tkinter.W+tkinter.S + tkinter.N) # 设置说明
  766. a_y += 1
  767. tkinter.Label(top, text='修改(列号):', bg=bg, fg=fg, font=FONT, width=width_B, height=height_B).grid(column=a_x,row=a_y) # 设置说明
  768. Dtype_Column = tkinter.Entry(top, width=width_B * 2)
  769. Dtype_Column.grid(column=a_x + 1, row=a_y, columnspan=2, sticky=tkinter.E + tkinter.W)
  770. a_y += 1
  771. tkinter.Label(top, text='数据类型:', bg=bg, fg=fg, font=FONT, width=width_B, height=height_B).grid(column=a_x,row=a_y) # 设置说明
  772. Dtype_Input = tkinter.Entry(top, width=width_B * 2)
  773. Dtype_Input.grid(column=a_x + 1, row=a_y, columnspan=2, sticky=tkinter.E + tkinter.W)
  774. a_y += 1
  775. tkinter.Label(top, text='错误值:', bg=bg, fg=fg, font=FONT, width=width_B, height=height_B).grid(column=a_x,row=a_y) # 设置说明
  776. Dtype_Wrong = tkinter.Entry(top, width=width_B * 2)
  777. Dtype_Wrong.grid(column=a_x + 1, row=a_y, columnspan=2, sticky=tkinter.E + tkinter.W)
  778. a_y += 1
  779. tkinter.Button(top, bg=bbg, fg=fg, text='执行转换',command=DTYPE, font=FONT, width=width_B,
  780. height=height_B).grid(column=a_x, row=a_y, sticky=tkinter.E + tkinter.W + tkinter.W+tkinter.S + tkinter.N)
  781. Dtype_Func = tkinter.IntVar()#正,负,0
  782. lable = ['硬转换','软转换']#复选框
  783. for i in range(2):
  784. tkinter.Radiobutton(top,bg = bg,fg = fg,activebackground=bg,activeforeground=fg,selectcolor=bg,text=lable[i],
  785. variable=Dtype_Func, value=i).grid(column=a_x+1+i, row=a_y, sticky=tkinter.W)
  786. a_x += 3
  787. tkinter.Label(top, text='', bg=bg, fg=fg, font=FONT, width=1).grid(column=a_x,row=a_y) # 设置说明
  788. a_x += 1
  789. a_y = 0
  790. tkinter.Label(top, text='【行名与列名】', bg=bg, fg=fg, font=FONT, width=width_B*3, height=height_B).grid(column=a_x,
  791. columnspan=3,row=a_y, sticky=tkinter.E + tkinter.W + tkinter.W+tkinter.S + tkinter.N) # 设置说明
  792. global replace_Dic,Repalce_RC,replace_iloc,Date_Input,RC_Type
  793. a_y += 1
  794. Repalce_RC = tkinter.IntVar()
  795. lable = ['(列数据)调整行名','(行数据)调整列名']#复选框
  796. for i in range(2):
  797. tkinter.Radiobutton(top,bg = bg,fg = fg,activebackground=bg,activeforeground=fg,selectcolor=bg,text=lable[i],
  798. variable=Repalce_RC, value=i).grid(column=a_x+i, row=a_y, sticky=tkinter.W)
  799. tkinter.Button(top, bg=bbg, fg=fg, text='植入行(列)号',command=num_withName, font=FONT, width=width_B,height=height_B).\
  800. grid(column=a_x+2, row=a_y, sticky=tkinter.E + tkinter.W)
  801. a_y += 1
  802. RC_Type = []
  803. lable = ['保留原值','保留新值']#复选框
  804. for i in range(2):
  805. RC_Type.append(tkinter.IntVar())
  806. tkinter.Checkbutton(top,bg = bg,fg = fg,activebackground=bg,activeforeground=fg,selectcolor=bg, text=lable[i],
  807. variable=RC_Type[-1]).grid(column=a_x+i, row=a_y, sticky=tkinter.W)
  808. tkinter.Button(top, bg=bbg, fg=fg, text='统一行号',command=num_toName, font=FONT, width=width_B,height=height_B).\
  809. grid(column=a_x+2, row=a_y, sticky=tkinter.E + tkinter.W)
  810. a_y += 1
  811. tkinter.Label(top, text='替换字典:', bg=bg, fg=fg, font=FONT, width=width_B, height=height_B).grid(column=a_x,row=a_y) # 设置说明
  812. replace_Dic = tkinter.Entry(top, width=width_B * 2)
  813. replace_Dic.grid(column=a_x + 1, row=a_y, columnspan=2, sticky=tkinter.E + tkinter.W)
  814. a_y += 1
  815. tkinter.Label(top, text='替换列(行):', bg=bg, fg=fg, font=FONT, width=width_B, height=height_B).grid(column=a_x,row=a_y) # 设置说明
  816. replace_iloc = tkinter.Entry(top, width=width_B * 2)
  817. replace_iloc.grid(column=a_x + 1, row=a_y, columnspan=2, sticky=tkinter.E + tkinter.W)
  818. a_y += 1
  819. tkinter.Button(top, bg=bbg, fg=fg, text='执行替换已有列(行)操作',command=Change_Index, font=FONT, width=width_B*2, height=height_B). \
  820. grid(column=a_x,columnspan=2, row=a_y, sticky=tkinter.E + tkinter.W)
  821. tkinter.Button(top, bg=bbg, fg=fg, text='执行替换操作',command=Replace_Index, font=FONT, width=width_B,height=height_B).\
  822. grid(column=a_x+2, row=a_y, sticky=tkinter.E + tkinter.W)
  823. label = ['起点','终点','间隔']
  824. Date_Input = []
  825. for i in range(3):
  826. a_y += 1
  827. tkinter.Label(top, text='时间序列'+label[i], bg=bg, fg=fg, font=FONT, width=width_B, height=height_B).grid(column=a_x,row=a_y) # 设置说明
  828. Date_Input.append(tkinter.Entry(top, width=width_B * 2))
  829. Date_Input[-1].grid(column=a_x + 1, row=a_y, columnspan=2, sticky=tkinter.E + tkinter.W)
  830. global Date_Type
  831. a_y += 1
  832. Date_Type = tkinter.IntVar()
  833. tkinter.Button(top, bg=bbg, fg=fg, text='刷入Date序列',command=Date_Index, font=FONT, width=width_B,height=height_B).\
  834. grid(column=a_x, row=a_y, sticky=tkinter.E + tkinter.W)
  835. tkinter.Button(top, bg=bbg, fg=fg, text='刷入Time序列',command=Time_index, font=FONT, width=width_B, height=height_B). \
  836. grid(column=a_x+1, row=a_y, sticky=tkinter.E + tkinter.W)
  837. tkinter.Checkbutton(top, bg=bg, fg=fg, activebackground=bg, activeforeground=fg, selectcolor=bg, text='使用间隔',
  838. variable=Date_Type).grid(column=a_x + 2, row=a_y, sticky=tkinter.W)
  839. top.mainloop()
  840. #出现在此下面的函数应转移到上方方便管理!......
  841. def Replace_Index():
  842. global replace_Dic, Repalce_RC,ML
  843. name = get_Name()
  844. Dic = eval(replace_Dic.get())
  845. is_Column = bool(Repalce_RC.get()) #操作行-False,操作列-True
  846. save = bool(RC_Type[0].get())
  847. ML.Replace_Index(name,is_Column,Dic,save)
  848. Updat_BOX()
  849. def Change_Index():
  850. global Repalce_RC, replace_iloc, RC_Type,ML
  851. name = get_Name() # 名字
  852. is_Column = bool(Repalce_RC.get()) # 操作行名-False,操作列名-True
  853. iloc = int(replace_iloc.get()) # 替换的列号(行号)
  854. save = bool(RC_Type[0].get())
  855. drop = not bool(RC_Type[1].get())
  856. ML.Change_Index(name,is_Column,iloc,save,drop)
  857. Updat_BOX()
  858. def num_toName():
  859. global Repalce_RC, replace_iloc, RC_Type,ML
  860. name = get_Name() # 名字
  861. is_Column = bool(Repalce_RC.get()) # 操作行名-False,操作列名-True
  862. save = bool(RC_Type[0].get())
  863. ML.num_toName(name,is_Column,save)
  864. Updat_BOX()
  865. def num_withName():
  866. global Repalce_RC,RC_Type,ML
  867. name = get_Name() # 名字
  868. is_Column = bool(Repalce_RC.get()) # 操作行名-False,操作列名-True
  869. save = bool(RC_Type[0].get())
  870. ML.num_withName(name,is_Column,save)
  871. Updat_BOX()
  872. def DateTime_Index(is_Date=True):
  873. global Repalce_RC, RC_Type,ML,Date_Input,Date_Type
  874. name = get_Name() # 名字
  875. is_Column = bool(Repalce_RC.get()) # 操作行名-False,操作列名-True
  876. save = bool(RC_Type[0].get())
  877. k = ['start','end','freq']
  878. Init = {}
  879. for i in range(len(Date_Input)):
  880. Input = Date_Input[i].get()
  881. if Input == '':continue
  882. Init[k[i]] = Input
  883. if len(Init) == 3:
  884. if bool(Date_Type.get()):#使用间隔
  885. del Init['end']
  886. else:
  887. del Init['freq']
  888. if is_Date:
  889. ML.Date_Index(name,is_Column,save,**Init)
  890. else:
  891. ML.Time_Index(name, is_Column, save, **Init)
  892. Updat_BOX()
  893. def Date_Index():
  894. DateTime_Index(True)
  895. def Time_index():
  896. DateTime_Index(False)
  897. if __name__ == '__main__':
  898. Machine_learning()