Thanks much, Dan and Eric, for your response to my post.
What triggered the post was finding anomalous PE ratios for a few stocks that had negative earnings—APA and SHLD. The attached notebook extracts prices, earnings per share, and price-earnings ratios for these two stocks and five others (SBUX, IBM, AAPL, TSLA, and TWTR).
SBUX, IBM, and AAPL all had positive earnings in the past quarter and fiscal year; pe_ratio for these stocks appear to have been calculated as price divided by annual earnings per share for the last 12 months. To verify this, I went to the Morningstar web site and looked up earnings per share. It would be useful if the documentation of Morningstar fundamental data made clear what data items are quarterly and what are annual. The documentation just says that pe_ratio is price divided by EPS, without specifying whether EPS is the last quarter, the last 12 months, or the last fiscal year.
Both TSLA and TWTR had negative earnings per share in the last quarter and last 12 months. For each of these, the pe_ratio is, appropriately, not a number (NaN).
The problem arises with SHLD and APA. Both these stocks had negative earnings in the last 12 months but pe_ratio is a positive number—69.4 for SHLD and 18.0 for APA.