My questions here are quite simple, as I am a beginner. I have the following problems.
I have a 2-day stock price data with 7 Time Points, i.e. 14 rows. DataFrame columns are DATE, Time_IDX, and Price, i.e. 3 columns. Time_IDX = [1, 2, 3, 4, 5, 6, 7], which repeats daily. There are 14 Prices, for example, df[‘Price’] = [288, 298, 301, 289, 300, 287, 295, 302, 305, 310, 299, 300, 285, 290]. I would like to create a variable called df[‘Price_0’] = [288,288,288,288,288,288,288,302,302,302,302,302,302,302]. This problem seems quite simple, but I have gotten into so many problems.
I have been struggling over creating a new column, daily df[‘Beg_Price’], showing the Beginning Price for Time_IDX = 1; and all other remaining 6 prices are identical to this Beg_Price.
I would really appreciate it if someone sees what beginners often miss when coding. Thanks.
I tried groupby with DATE, or Time_IDX; and with loc method. I also tried by setting indexes with Time_IDX as well. However, the number in the df is not unique, and so I failed. Thanks.
T Rhee is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.