Как найти корреляцию между данными временных рядов и построить график в Python - PullRequest
2 голосов
/ 22 марта 2019

У меня есть следующие данные:

String  Value   datetime
hello   10  10/3/2017 0:00
hello   45  10/4/2017 0:00
hello   544 10/5/2017 0:00
hello   677 10/6/2017 0:00
hello   899 10/7/2017 0:00
hello   67  10/8/2017 0:00
hello   88  10/9/2017 0:00
hello   77  10/10/2017 0:00
Hi  55  10/3/2017 0:00
Hi  99  10/4/2017 0:00
Hi  33  10/5/2017 0:00
Hi  22  10/6/2017 0:00
Plant   11  10/3/2017 0:00
Plant   44  10/4/2017 0:00
Plant   55  10/5/2017 0:00
Plant   661 10/6/2017 0:00

Я хочу найти корреляцию между строковыми значениями и построить линейный график с этими тремя столбцами, и я использую следующий код:

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

df = pd.read_excel(r'test.xlsx')
df.head()
##to find the correlation between string and the value
s_corr = df.String.str.get_dummies(sep=' ').corrwith(df.Value)
print (s_corr)
#Plot the graph
df.set_index('datetime', inplace=True)
df.plot()

Но когда я строю график, график строит график с указанием даты и времени, но я хочу построить график с тремя столбцами.Как это сделать?

...