Skip to content

Commit c427c63

Browse files
author
krasoa
committed
Changed Dataframe column selection to df["column_name"]. Was inconsistent before. + corrected Mickey Mouse and Minnie Mouses names and column placement.
1 parent ddf501b commit c427c63

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

03-2020-11-20/notebooks/03-03-The_pandas_library.ipynb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -851,7 +851,7 @@
851851
"metadata": {},
852852
"outputs": [],
853853
"source": [
854-
"df.no_of_songs > 50"
854+
"df[\"no_of_songs\"] > 50"
855855
]
856856
},
857857
{
@@ -860,7 +860,7 @@
860860
"metadata": {},
861861
"outputs": [],
862862
"source": [
863-
"df.loc[df.no_of_songs > 50]"
863+
"df.loc[df[\"no_of_songs\"] > 50]"
864864
]
865865
},
866866
{
@@ -869,7 +869,7 @@
869869
"metadata": {},
870870
"outputs": [],
871871
"source": [
872-
"df.loc[(df.no_of_songs > 50) & (df.year_born >= 1942)]"
872+
"df.loc[(df[\"no_of_songs\"] > 50) & (df[\"year_born\"] >= 1942)]"
873873
]
874874
},
875875
{
@@ -878,7 +878,7 @@
878878
"metadata": {},
879879
"outputs": [],
880880
"source": [
881-
"df.loc[(df.no_of_songs > 50) & (df.year_born >= 1942), [\"Last Name\", \"Name\"]]"
881+
"df.loc[(df[\"no_of_songs\"] > 50) & (df[\"year_born\"] >= 1942), [\"Last Name\", \"Name\"]]"
882882
]
883883
},
884884
{
@@ -904,7 +904,7 @@
904904
"outputs": [],
905905
"source": [
906906
"from numpy import nan\n",
907-
"df.loc[5] = [\"Mouse\", \"Mickey\", nan, 1928, nan]\n",
907+
"df.loc[5] = [\"Mickey\", \"Mouse\", nan, 1928, nan]\n",
908908
"df"
909909
]
910910
},
@@ -973,7 +973,7 @@
973973
"metadata": {},
974974
"outputs": [],
975975
"source": [
976-
"df.loc[5, \"Name\"] = \"Mini\" "
976+
"df.loc[5, \"Name\"] = \"Minnie\" "
977977
]
978978
},
979979
{
@@ -1098,7 +1098,7 @@
10981098
"df[\"age\"].plot.bar(ax=ax)\n",
10991099
"\n",
11001100
"# add some customization to the Axes object\n",
1101-
"ax.set_xticklabels(df.Name, rotation=0)\n",
1101+
"ax.set_xticklabels(df[\"Name\"], rotation=0)\n",
11021102
"ax.set_xlabel(\"\")\n",
11031103
"ax.set_ylabel(\"Age\", size=14)\n",
11041104
"ax.set_title(\"The Beatles and ... something else\", size=18);"

0 commit comments

Comments
 (0)