Search code examples
pythonpandasyahoo-finance

Reading Yahoo Finance: Extract a smaller table from a bigger table Python (historical low price)


I have a table from yahoo finance with one year of data

The table is like the figure below

enter image description here

enter image description here

I want to join two columns of this table to make a new one. I want the column date and price

Does anyone can give me a tip?


Solution

  • I got the first part of your question, where you only want to see a table (pandas dataframe) with columns date and low.

    Column selection in pandas is very easy. You put the list of columns you like to see in a python list, and then pass it to dataframe in way you subset.

    mycolumns = ["date", "low"]
    newdf = bvsp2[mycolumns]
    print(newdf)
    

    Output

              date      low
    0   2017-02-16  67661.0
    1   2017-02-17  67158.0
    2   2017-02-20  67756.0
    3   2017-02-21  68536.0
    4   2017-02-22  68282.0
    ..         ...      ...