From 0730f7537546293b54bd9eea15657a841c412341 Mon Sep 17 00:00:00 2001 From: ChallenUW <158841953+ChallenUW@users.noreply.github.com> Date: Mon, 6 May 2024 09:56:23 -0700 Subject: [PATCH] Update pandas.html A student noticed that section 9.2 of the book (that describes auto sorting of indices when creating a series from a labeled dictionary) conflicts with the video in Module 5.1.2. This is due to a change in the pandas library for python 3.6+ that no longer auto sorts. Release note here: https://pandas.pydata.org/docs/dev/whatsnew/v0.23.0.html#instantiation-from-dicts-preserves-dict-insertion-order-for-python-3-6 Book text revised to show the properly non-sorted series output as well as remove the paragraph that describes auto-sorting. --- build/pandas.html | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/build/pandas.html b/build/pandas.html index 4b0ce05..c7e6941 100644 --- a/build/pandas.html +++ b/build/pandas.html @@ -369,11 +369,10 @@
# create a Series from a dictionary
age_series = pd.Series({'sarah': 42, 'amit': 35, 'zhang': 13})
print(age_series)
-amit 35
-sarah 42
+sarah 42
+amit 35
zhang 13
dtype: int64
-Notice that the Series is automatically sorted by the keys of the dictionary! This means that the order of the elements in the Series will always be the same for a given dictionary (which cannot be said for the dictionary items themselves).
9.2.1 Series Operations
The main benefit of Series (as opposed to normal lists or dictionaries) is that they provide a number of operations and methods that make it easy to consider and modify the entire Series, rather than needing to work with each element individually. These functions include built-in mapping and filtering style operations, as well as reducing aggregations.