1

When I try printing to screen, or saving to a text file, the output from downloading stocks through yfinance, it truncates the output like so:

                          Adj Close                ...   Volume
                               ADXS  CHEK    CLPS  ...     TUSK     TYHT     VOXX
Datetime                                           ...
2020-01-28 07:00:00-05:00    0.7900   NaN     NaN  ...      NaN      NaN      NaN
2020-01-28 08:00:00-05:00    0.8090   NaN     NaN  ...      NaN      NaN      NaN
2020-01-28 09:00:00-05:00    0.7799   NaN     NaN  ...      NaN      NaN      NaN
2020-01-28 09:30:00-05:00    0.7990  2.10  3.5000  ...      0.0      0.0      0.0
2020-01-28 10:30:00-05:00    0.7897  2.12  3.4283  ...  11931.0  27734.0   5196.0
...                             ...   ...     ...  ...      ...      ...      ...
2020-02-14 14:30:00-05:00    1.0300  1.73  3.1087  ...  10005.0  13814.0  14255.0
2020-02-14 15:30:00-05:00    1.0199  1.75  3.0800  ...  15483.0   6871.0   7046.0
2020-02-14 16:00:00-05:00    1.0100   NaN     NaN  ...      0.0      0.0    400.0
2020-02-14 17:00:00-05:00    1.0000   NaN     NaN  ...      NaN      0.0      NaN
2020-02-14 18:00:00-05:00    1.0100   NaN     NaN  ...      0.0      NaN      NaN

[215 rows x 156 columns]

Going from How to print the full NumPy array, without truncation? I tried adding:

np.set_printoptions(precision=3, suppress=True, threshold=np.inf)
#As well as 
np.set_printoptions(precision=3, suppress=True, threshold=sys.maxsize)

While that will print large arrays, it still has no effect on the output.

I then tried doing a for loop and a for loop inside the for loop, but that just printed the titles.

Here is what I have for this part:

rangeOfDays=21
endDateRange= datetime.date.today()- datetime.timedelta(days=(rangeOfDays+1))
startDateRange= EndTestingDate - datetime.timedelta(days=(730-rangeOfDays))
timeBetweenDates = endDateRange- startDateRange
daysBetweenDates = timeBetweenDates.days                            
randomNumOfDays = random.randrange(daysBetweenDates)                
randomDay= startDateRange + datetime.timedelta(days=randomNumOfDays)  
lastDay=randomDay + datetime.timedelta(days=(dayRange))
#All of this is just the date stuff


StockNames =['LODE', 'CLPS', 'CNET', 'NXTD', 'PBTS', 'PETZ', 'GRNQ', 'PHCF', 'MTC', 'PCSA', 'TUSK']
Break=yf.download(StockNames, start=randomDay, 
                          end=lastDay, 
                          progress=True, 
                          interval ='60m',
                          prepost=True, 
                          threads=100)
Break.head()
print (Break)

Is there even a way to spread it out to print to the screen or save to a file the full amount?

calebhk98
  • 157
  • 1
  • 4
  • 15
  • Are you sure this is a NumPy array, not a Pandas DataFrame? That will make a difference as to which option to set for the output. – 9769953 Apr 21 '21 at 00:14
  • Of course you can save it to file: [`numpy.savetxt`](https://numpy.org/doc/stable/reference/generated/numpy.savetxt.html) is one option, but since I suspect this may be a Pandas DataFrame, [`Break.to_csv(...)`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.to_csv.html) is perhaps the more logical choice. – 9769953 Apr 21 '21 at 00:15
  • @00 I am not sure. I didn't see anything online about how pandas might truncate anything, so I assumed it wasn't involved. I will look for something related to that again. – calebhk98 Apr 21 '21 at 00:17
  • @00 I tried pd.option_context('display.max_rows', None, 'display.max_columns', None), and it didn't change anything, but to_string() fixes it for the main list! Now I just have to find a way to save only the parts I want. If you post your comment as an answer, I'll accept it. – calebhk98 Apr 21 '21 at 00:27
  • Save the parts you want: as in specific columns, or specific rows? – 9769953 Apr 21 '21 at 00:32
  • @00 Save specific rows. I have it working now pretty well. Thanks for the help. I didn't even realize Pandas Dataframes weren't list to begin with, so you massively helped me. – calebhk98 Apr 21 '21 at 01:25

1 Answers1

3

Try this if all you're after is for the full frame to be printed. Worked for me in the past. Credit to some other Stackoverflow post where I got it:

import pandas as pd
pd.set_option('display.max_rows', None)
pd.set_option('display.max_columns', None)
pd.set_option('display.width', None)
pd.set_option('display.max_colwidth', None)
Dmytro Bugayev
  • 606
  • 9
  • 13
  • I saw this as well, and it might be useful for other people, but it didn't work for me. I had to use to_string(). – calebhk98 Apr 21 '21 at 01:24