Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pandas as pd
- import matplotlib.pyplot as plt
- import numpy as np
- import scipy.stats
- from statsmodels.graphics.tsaplots import plot_acf
- import scipy
- import spectrochempy as scp
- #https://scicoding.com/4-ways-of-calculating-autocorrelation-in-python/
- if __name__ == '__main__':
- df = pd.read_csv('CompanyABCProfit.csv').set_index('Year')
- fig = plt.figure(figsize=(10, 10))
- plt.xlabel('Year')
- plt.ylabel('Profit')
- # df.plot()
- # plt.close()
- values_df = []
- for value in df["Profit(Rs '000)"]:
- values_df.append(value)
- corr_func = (np.correlate(values_df - df.mean()[0], values_df - df.mean()[0], 'full')) / df.var()[0] / len(values_df)
- fig = plt.figure(figsize=(10, 10))
- corr_function = pd.DataFrame(corr_func).reset_index()
- corr_function['index'] = corr_function['index'] - len(df)
- corr_function = corr_function.set_index('index')
- corr_function.plot()
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement