選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

wilshire.py 1001B

1234567891011121314151617181920212223242526272829303132333435
  1. import numpy as np
  2. import tensorflow as tf
  3. import pandas as pd
  4. import matplotlib.pyplot as plt
  5. def parser(path):
  6. df = pd.read_csv(path,na_values='.')
  7. print(df.shape)
  8. #df = df.interpolate()
  9. df = df.dropna().reset_index(drop=True)
  10. print(df.shape)
  11. #df = df.drop(labels=np.arange(1825)) ### To obtain the same graph than in the article
  12. print(df.shape)
  13. return(df)
  14. def preprocess(path):
  15. df = parser(path)
  16. df_normalized = df[:]
  17. df_normalized["WILL5000INDFC"]=df_normalized["WILL5000INDFC"]/np.max(df_normalized["WILL5000INDFC"])
  18. index_train = int(df_normalized[df_normalized["DATE"]=="2020-01-31"].index.array[0])
  19. print(df)
  20. print(df_normalized)
  21. print(df_normalized[df_normalized["DATE"]=="2020-01-31"])
  22. # df.plot()
  23. # plt.show()
  24. df_train = df_normalized[:index_train]
  25. df_test = df_normalized[index_train+1:index_train+85]
  26. # df_train.plot()
  27. # df_test.plot()
  28. # plt.show()
  29. return(df_train,df_test,index_train)