Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pandas as pd
- import numpy as np
- df = pd.read_csv("/Users/Dimitrios/Desktop/Stock_data/2019_12/06/HM.csv")
- #Prints the rows for all columns when the Tid column value is True with the statment
- #print(df.loc[df["Tid"]=="2019-12-06 17:29:53"])
- #Makes index value based on the Tid column
- df2 = pd.read_csv("/Users/Dimitrios/Desktop/Stock_data/2019_12/06/HM.csv", index_col="Tid")
- #print(df2.at["2019-12-06 17:29:53","Volym"])
- #Makes a column thats Kurs * Volym
- Total_summa = df2["Kurs"]*df2["Volym"]
- #Add the new column on the positioon 11 in the df. The others are pushed to the right
- df2.insert(11, "Total Summa", Total_summa, True)
- #Makes all the index values to a list
- #Total_summa.index.tolist()
- #Creates a dataframe from df2 with only 3 choosen columns
- df3 = df2.loc[:, ['Kurs', 'Volym', 'Total Summa']]
- listi = []
- for i in Total_summa.index.tolist():
- if i not in listi:
- listi.append(i)
- sumisum = []
- print(listi[0:5])
- print(Total_summa.index.tolist()[0:3])
- for i in listi[0:3]:
- print(i)
- b = df3.at[str(i),"Total Summa"]
- b = sum(b)
- sumisum.append(b)
- print(sumisum)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement