test.py 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. from re import A
  2. import pandas as pd
  3. import numpy as np
  4. from pandas.core.frame import DataFrame
  5. from scipy import interpolate
  6. import matplotlib.pyplot as plt
  7. import bisect
  8. import datetime,time
  9. import operator
  10. from six import b
  11. import skfuzzy as fuzz
  12. import skfuzzy.control as ctrl
  13. import os
  14. from scipy.interpolate import interp2d
  15. from apscheduler.schedulers.blocking import BlockingScheduler
  16. from LIB.MIDDLE.CellStateEstimation.Common import BatParam
  17. # def fun1():
  18. # print('job1')
  19. # print(datetime.datetime.now())
  20. # time.sleep(3)
  21. # def fun2():
  22. # print('job2')
  23. # print(datetime.datetime.now())
  24. # time.sleep(3)
  25. # scheduler = BlockingScheduler()
  26. # scheduler.add_job(fun1, 'interval', seconds=5)
  27. # scheduler.add_job(fun2, 'interval', seconds=5)
  28. # scheduler.start()
  29. # a=8
  30. # for i in range(a):
  31. # with open('soc.txt','a') as file:
  32. # file.write(str(a)+'\n')
  33. # a=a+1
  34. # a={'1':123,'2':234,'3':456}
  35. # b=list(a.values())
  36. # print(b)
  37. # print(b[1])
  38. # a=pd.DataFrame(columns=['a','b'])
  39. # a['a']=[1,3,1,2,4]
  40. # a['b']=[1,2,3,4,5]
  41. # # a=a.sort_values(by='a',ascending=True)
  42. # a=a.drop('b',axis=1)
  43. # print(a)
  44. column_name=['time', 'sn', 'short_current']
  45. df_res=pd.DataFrame(columns=column_name)
  46. df_res.loc[1]=[1,1.5,1]
  47. df_res.loc[2]=[1,-2.5,2]
  48. df_res.loc[3]=[-1,3.5,3]
  49. df_res.loc[4]=[3,-4.5,4]
  50. df_res.reset_index(inplace=True,drop=True) #重置索引
  51. df_res=df_res[(df_res[['time','sn']]>0) & (df_res[['time','sn']]<3)]
  52. print(df_res)
  53. # column_name=['time', 'sn', 'soc']
  54. # df_res1=pd.DataFrame(columns=column_name)
  55. # df_res1.loc[1]=[1,1,3.330]
  56. # df_res1.loc[2]=[1,2,3.330]
  57. # df=df_res.append(df_res1)
  58. # print(df)
  59. # df_res1=pd.DataFrame(columns=column_name)
  60. # df_res1.loc[1]=[1,1,3.330]
  61. # df_res.append(df_res1,ignore_index=True)
  62. # # print(df_res.drop(df_res.loc[df_res['sn']==3].index))
  63. # print(df_res)
  64. # import time
  65. # import datetime
  66. # from apscheduler.schedulers.blocking import BlockingScheduler
  67. # def add(a):
  68. # a=a+1
  69. # return a
  70. # def func():
  71. # #耗时2S
  72. # global a
  73. # now = datetime.datetime.now()
  74. # ts = now.strftime('%Y-%m-%d %H:%M:%S')
  75. # a=add(a)
  76. # print('do func2 time:',ts)
  77. # print(a)
  78. # # time.sleep(5)
  79. # if __name__=="__main__":
  80. # a=1
  81. # scheduler = BlockingScheduler()
  82. # scheduler.add_job(func, 'interval', seconds=1, id='test_job1')
  83. # scheduler.start()