I saw this line of code from a book, what does that mean? After that, I print portfolio, it is just a underscore, but it is not empty DataFrame.
portfolio = portfolio = pd.DataFrame()
You're seeing the result of how an empty DataFrame is displayed,. The DataFrame is in fact empty; you can see this better using a print
or checking the empty
attribute.
import pandas as pd
df = pd.DataFrame()
display(df)
#_
print(df)
#Empty DataFrame
#Columns: []
#Index: []
df.empty
#True
portfolio = pd.DataFrame()
does create an empty DataFrame where you can then add columns like e.g. portfolio['my_col'] = np.zeros(10)
. I'm note sure I understand your question, could you give some more information?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With