from pandas import DataFrame
data = {'open': [100, 200], "high": [110, 210]}
df = DataFrame(data )
print(df)
open high
0 100 110
1 200 210
from pandas import DataFrame
data = {"open": [737, 750], "high": [755, 780], "low": [700, 710], "close": [750, 770]}
df = DataFrame(data , index=["2018-01-01", "2018-01-02"])
print(df)
open high low close
2018-01-01 737 755 700 750
2018-01-02 750 780 710 770
엑셀 읽기/쓰기
import pandas as pd
# 읽기
df_r = pd.read_excel("C:\\ohlc.xlsx")
print(df_r)
# 쓰기
df.to_excel("C:\\ohlc-2.xlsx")
from pandas import DataFrame
data = {"open": [730, 750], "high": [755, 780], "low": [700, 710], "close": [750, 770]}
df = DataFrame(data , index=["2018-01-01", "2018-01-02"])
print(df['open'])
print(df.loc["2018-01-01"])
2018-01-01 730
2018-01-02 750
Name: open, dtype: int64
open 730
high 755
low 700
close 750
Name: 2018-01-01, dtype: int64
from pandas import DataFrame
data = {"open": [737, 750], "high": [755, 780], "low": [700, 710], "close": [750, 770]}
df = DataFrame(data)
s = Series([300, 400])
df['volume'] = s
print(df)