I have a data
which I am trying to store in pandas
dataFrame. But, it is appearing in a weird way. I know I am doing something wrong
Can somebody help me in finding whats wrong.
Code
root@optstra:~# cat pandas_1.py
import pandas as pd
import numpy as np
numberOfRows = 1
SYMBOL = 'ABB'
volume_increasing = True
price_increase = True
OI_CHANGE = True
closedAboveYesterday = False
Above_22SMA = False
data_frame = pd.DataFrame(index=np.arange(0, numberOfRows), columns=('SYMBOL','Volume', 'Price', 'OI','OHLC','22SMA') )
for x in range(0,numberOfRows):
data_frame.loc[x] = [{SYMBOL,volume_increasing,price_increase,OI_CHANGE,closedAboveYesterday,Above_22SMA} for n in range(6)]
print(data_frame)
Output
root@optstra:~# python3 pandas_1.py
SYMBOL Volume Price OI OHLC 22SMA
0 {False, True, ABB} {False, True, ABB} {False, True, ABB} {False, True, ABB} {False, True, ABB} {False, True, ABB}
If I change the line which writes the data to data frame as follows
for x in range(0,numberOfRows):
data_frame.loc[x] = [(SYMBOL,volume_increasing,price_increase,OI_CHANGE,closedAboveYesterday,Above_22SMA) for n in range(6)]
Output changes to
root@optstra:~# python3 pandas_1.py
SYMBOL ... 22SMA
0 (ABB, True, True, True, False, False) ... (ABB, True, True, True, False, False)