0

I am new to python. Just following some sample code this is the error I get:

'DataFrame' object has no attribute 'to_frame'

import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
import numpy as np
import statsmodels
import statsmodels.api as sm
from datetime import datetime


tech_list =['4938.TW','2317.TW']
tickers=['4938.TW','2317.TW']
end= '2014-12-31'
start= '2014-01-01'
print(start)
print (end)

from pandas_datareader import data as pdr
import fix_yahoo_finance as yf
yf.pdr_override(tickers)
data=pdr.get_data_yahoo(tech_list,start,end) 
data.to_frame().head(10)

I want to get this

enter image description here

enter image description here

3
  • I think you are trying to covert the dataframe. Try data.head(10) and let me know the result. Commented Jul 18, 2019 at 14:34
  • 1
    ok i know why error. because data is dataframe so can't to frame? i try code data.head(10) but the form not same . how can i merge Symbols to same ? Commented Jul 18, 2019 at 16:26
  • Already Answered here: Click here Commented Sep 5, 2020 at 15:40

1 Answer 1

0

The problem is that your 'data' variable is already a dataframe. Check with print(type(data))

since it's already a dataframe you can use

print(data.head(10))

to get your result

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.