Python for Data Science for Dummies Errata on Page 145

Python for Data Science for Dummies contains two errors on page 145. The first error appears in the second paragraph on that page. You can safely disregard the sentence that reads, “The use_idf controls the use of inverse-document-frequency reweighting, which is turned off in this case.” The code doesn’t contain a reference to the use_idf parameter. However, you can read about it on the Scikit-Learn site. This parameter defaults to being turned on, which is how it’s used for the example.

The second error is also in the second paragraph. The discussion references the tf_transformer.transform() method call. The actual method call is tfidf.transform(), which does appear in the sample code. The discussion about how the method works is correct, just the name of the object is wrong.

Please let me know if you have any questions about either of these changes at [email protected]. I’m sorry about any errors that appear in the book and appreciate the readers who have pointed them out.

 

Adding Vinegar to the Chicken Water

It’s winter in Wisconsin and the chicken coop isn’t heated. In fact, the chicken coop lacks an electrical connection as well, so except for taking pots of heated water in on the coldest days, trying to heat the coop must come from other sources. The slant of the roof and placement of the window ensure that the coop receives maximum winter heat. The tree that normally shields the coop from the sun during the summer months is bare, letting the sun come through. Even with all these measures, the coop is cold enough to let the chicken’s water freeze.

My goals for various activities on my small farm include doing things in a manner that makes my carbon footprint small and keeps costs low. Consequently, I always look for solutions that don’t involve much in the way of high technology, such as obtaining heated chicken waterers. I did seriously look at a solar powered unit for a while, but decided that the chickens would probably destroy it in short order. The better solution turned out to be adding vinegar to the chicken water.

It turns out that vinegar has both a lower freezing temperature and higher boiling point than water. The freezing temperature of vinegar is 28 degrees, but that level increases when you add more water. I tried various levels of vinegar in the chicken water and found that ½ cup per gallon seems to keep the water from freezing for about an hour longer when the outside temperature is in the 15 to 30 degree range. Above 30 degrees, it kept the water from freezing at all.

Adding vinegar to the water also keeps anything from growing inside the waterer, which means that the water is better for the chickens longer. This feature of adding vinegar is especially important during the summer, when all kinds of green gunk grows inside the waterer and is quite hard to keep out.

If you look on other websites, you find that other people attribute all sorts of other benefits to using vinegar. Other websites warn against using vinegar. I haven’t personally tested any of these claims, so I’m not here to tell you that the chickens derive any benefit whatsoever from the vinegar in the water. However, I did try a simple experiment this past summer and found that given two buckets, precisely the same size, color, and make, one with vinegar and one without, the chickens always drank the vinegar water first. My feeling is that they seem to like it. So even if the chickens don’t gain any solid benefits from the vinegar, you can view it as a treat that helps keep the water from freezing longer and keeps their waterer cleaner. Let me know your thoughts on adding vinegar to the chicken water at [email protected].

 

Time to Check the Larder

The seed catalogs begin to arrive in the mail and you look upon them as a bit of pure heaven—the announcement that spring is on the way. Your eyes nearly pop out as you see the multicolored carrots, juicy tomatoes, and fragrant herbs. The new kinds of fruit trees immediately attract your attention, and what about that amazing new berry bush that will pack your freezer with sumptuous berries? You go into a mix of information and appetite overload and you consider just how those new offerings will satiate your cravings for all things fresh. However, before you go into a swoon over the latest delights, consider the fact that you probably don’t need them all. Your larder is craving things too! The items you’ve used up have created gaps in the deliciousness that your larder can provide during the winter months when fresh simply isn’t an option.

Of course, everyone loves to experiment. After all, that’s how I found kabocha squash this past summer—that delectable mix of sweet and savory that will likely find its way into a pie this upcoming fall. Had I known then what I know now, I would have planted more and canned the extra as an alternative to using pumpkin for pies. Lesson learned, more kabocha squash will find their way into the mix this year, alongside the butternut and acorn squash I love so well.

Back to the larder though. You probably don’t have any idea of where the holes are right now and you really do need to find out. That’s why you need to perform an inventory of your larder. The inventory will tell you about the items you need most. This year I’ve decided to try canning three bean salad, which means growing green, yellow wax, and kidney beans. However, I already have enough green beans in quarts in the larder, so I won’t make a big planting of green beans.

Your larder inventory should include more than a simple accounting. As you go through your larder, you should also perform these tasks:

  • Ensure all of the canned goods are still sealed
  • Wipe the jars down to remove the dust
  • Verify all of the oldest products are in the front
  • Make a list of products that are more than five years old so you can use them up
  • Place all the empty jars in one area
  • Sort the jars by type (both size and the kind of lid used)

Taking these extra steps will help you get a better handle on your larder. You should have a good idea of what your larder contains at all times and the only way to achieve that goal is to actually look at the containers. Let me know your thoughts about larder management at [email protected].

 

Using Jupyter with Anaconda (Updated)

A few readers have recently written to me regarding the use of Jupyter with the downloadable source for Python for Data Science for Dummies. The version of Anaconda recommended for the book, 2.1.0, doesn’t rely on Jupyter, which is why the book doesn’t mention Jupyter. The book relies on IPython Notebook, which is what you should use to obtain the best reading experience. You can obtain the proper version from the Continuum archive. However, if you choose to download the current version of Anaconda, then using Jupyter becomes a possibility; although, many of the procedures found in the book will require tweaking and the screenshots won’t match precisely.

In order to use Jupyter, you must still import the downloaded files into your repository. The source code comes in an archive file that you extract to a location on your hard drive. The archive contains a list of .ipynb (IPython Notebook) files containing the source code for this book (see the Introduction for details on downloading the source code). The following steps tell how to import these files into your repository:

  1. Click Upload at the top of the page. What you see depends on your browser. In most cases, you see some type of File Upload dialog box that provides access to the files on your hard drive.
  2. Navigate to the directory containing the files you want to import into Notebook.
  3. Highlight one or more files to import and click the Open (or other, similar) button to begin the upload process. You see the file added to an upload list, as shown here. The file isn’t part of the repository yet—you’ve simply selected it for upload.

    Click Upload when you want to upload files to the repository.
    Upload Source Files to the Repository
  4. Click Upload. Notebook places the file in the repository so that you can begin using it.

It’s important to both Luca and me that you have the best possible learning experience with our book. This means using the right version of Anaconda for most people. Using the latest version shouldn’t cause problems, but we’d like to know if it does. Please feel free contact me at [email protected] with your book-specific questions.


Update

It has come to our attention since this post first published that using the latest version of Anaconda with Python for Data Science for Dummies is problematic. Some of the examples won’t work without rewriting because the Pandas Categorical class has changed. This is the only change we’ve confirmed so far, but there are no doubt other changes. In order to get the proper results from the examples in the book, you must use the correct version of Anaconda, version 2.1.0.

Please do keep those questions coming. It’s because a reader took time to write that Luca and I became aware of this problem. We truly do want you to have a great learning experience, so these questions are important!

 

Calcium Nodules on Eggs

At some point during your time of working with chickens, you might encounter eggs that look like they have insect eggs on them. The view can be disquieting at first—all sorts of images could go through your mind. However, it’s more likely that what you’re actually seeing are calcium nodules that merely look like insect eggs. Here is an egg that has such nodules on it.

An egg may have harmless calcium nodules that look like insect eggs deposited on it.
Calcium nodules can look like insect eggs.

These nodules are completely harmless. In fact, you can wash them off the eggs quite easily. When crushed, the nodules feel gritty, much like crushed eggshell would feel. These nodules typically appear for two reasons:

The first reason is the one that occurs most often. Five of my hens are now four years old and one is five years old. The five year old hen (a Black Australorp) laid this egg, so the nodules aren’t unusual at all. (Most factory settings keep laying hens for one or two years after they start laying eggs, I’ve found that four years in optimal settings works well.) This spring I’ll replace two of the hens with new layers (the other four are pets and will die of old age). I also had one hen eaten by hawks and another died of an impacted egg, so I’ll actually get four new layers this spring.

I’m thinking of trying Barred Rocks (a kind of Plymouth Rock) because I’ve never had them before and they’re quite pretty. According Henderson’s Chicken Chart, they’re cold hard and produce large eggs. A friend of mine has them in her flock and feels that they’re a good investment. The point is that when you start seeing these nodules on one or two eggs and not on the eggs of your flock as a whole, you may need to start thinking about replacing the bird that laid it. Let me know your thoughts about keeping a healthy flock at [email protected].

 

Python for Data Science for Dummies Errata on Page 124

Python for Data Science for Dummies contains an error in the example that appears on the top half of page 124. In the first of the two grey boxes, the code computes the results of four print statements. The bottom-most print statement, print x[1:2, 1:2], is supposed to compute a result based on rows 1 and 2 of columns 1 and 2, and the bottom grey box seems to confirm that interpretation by the showing the result as [[[14 15 16] [17 18 19]] [[24 25 26] [27 28 29]]]. However, the answer provided for this example in the downloadable source code is [[[14 15 16]]], which doesn’t agree with that in the text.

The good news is that the downloadable source contains the correct code. The error appears only in the book. The last print statement in the book is wrong. Here is the correct code (with output) for this example:

x = np.array([[[1, 2, 3], [4, 5, 6], [7, 8, 9],],
 [[11,12,13], [14,15,16], [17,18,19],],
 [[21,22,23], [24,25,26], [27,28,29]]])

print x[1,1]
print x[:,1,1]
print x[1,:,1]
print
print x[1:3, 1:3]
[14 15 16]
[ 5 15 25]
[12 15 18]

[[[14 15 16]
 [17 18 19]]

[[24 25 26]
 [27 28 29]]]

Please let me know if you have any questions about this example at [email protected]. I’m sorry about the error that appears in the book and appreciate the readers who have pointed it out.

 

Getting the Fastest Question Response

I always want to be sure that you get fast, courteous responses to your book-specific questions. Even though I don’t check my e-mail every day, I do check it most days of the week, so that’s the fastest way to contact me regarding issues that you have with my books. Of course, you can make the response even faster by doing a few simple things when sending your email:

  • Be sure to include the name of the book and the book edition in the message subject line.
  • Tell me which page, figure, or listing number to look at in the book.
  • Document the steps you took.
  • Provide me with the exact error message you’re seeing.
  • Tell me about your platform (operating system, the version of any software you’re using, and so on).

If you provide these basic pieces of information, I can usually answer your questions much faster—often without asking for additional information. E-mail communication can be difficult at times because it lacks that in person body language element and you can’t show me what you’re seeing on your machine. Remote diagnostics are harder than you might think.

It’s also important that you understand that I focus on book-specific questions. I’ve discussed this issue before in Sending Comments on My Books and Sending Comments and Asking Questions. The bottom line is that I want you to be happy with your book experience, but I also don’t have time to provide free consulting. Please let me know if you have any questions or concerns about contacting me at [email protected].

 

New Look! New Features!

If you’re visiting my blog for the first time this year, you probably noticed a few changes in its appearance. Sometimes a site changes its appearance simply to provide a different look—to enhance its aesthetic appeal. It’s true that I had used the previous design for a number of years, but that’s not the reason for the changes you see today. These changes come as the result of input from the people who read my blog and took the time to comment on it.

The biggest change is one that you can’t readily see until you access my blog from a smartphone. My site now works well with devices of all sizes so that you can gain access to the information my blog provides from any location using any device. It took me a while to find a theme that I thought would preserve most of the look and feel of the original blog, but allow for this added functionality. Even though the feel is a little different, the addition of this feature is important to enough readers that I really want it to work well.

As part of making my blog easier to use, I also went for a cleaner look. The new format should work in a wider range of settings, even in bright sunlight (as well as anything works in bright sunlight). The larger type should also make it easier for people with special visual needs to see. I tested the new setup out on a number of monitors and find that it scales better than the old design too.

Part of the update also affects my web site. I wanted to provide better consistency between the two locations. Some viewers said it was a bit disconcerting to use one layout on the web site and another on the blog. My original intent had been to provide the best layout for each setting, but this method of configuring the two locations didn’t work nearly as well as I thought it would.

Of course, I always want your input because this site is specifically designed to meet your needs. I want the readers of my books to get maximum benefit from them, which means having a blog that actually meets those needs. If you see what you like or want to express concerns about issues you don’t like, please feel free to contact me at [email protected]. As always, your input is essential to the success of my books, my blog, and my other endeavors!

During the upcoming months I do plan to make additional changes. The blog has gotten a bit unwieldy, so I plan to remove some existing content to make room for new information. I’ll also be adding more linkage between my web site and the blog so that the two work better together. Your patience during this time of transition is greatly appreciated!