Skip to content

Commit ada7b6a

Browse files
committed
Data Frame
1 parent 3e17da0 commit ada7b6a

File tree

1 file changed

+79
-18
lines changed

1 file changed

+79
-18
lines changed

Pandas.ipynb

Lines changed: 79 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -637,31 +637,31 @@
637637
},
638638
{
639639
"cell_type": "code",
640-
"execution_count": 56,
640+
"execution_count": 71,
641641
"metadata": {},
642642
"outputs": [],
643643
"source": [
644-
"new='A B C D E'.split()"
644+
"newI='A B C'.split()"
645645
]
646646
},
647647
{
648648
"cell_type": "code",
649-
"execution_count": 57,
649+
"execution_count": 72,
650650
"metadata": {},
651651
"outputs": [
652652
{
653653
"data": {
654654
"text/plain": [
655-
"['A', 'B', 'C', 'D', 'E']"
655+
"['A', 'B', 'C']"
656656
]
657657
},
658-
"execution_count": 57,
658+
"execution_count": 72,
659659
"metadata": {},
660660
"output_type": "execute_result"
661661
}
662662
],
663663
"source": [
664-
"new"
664+
"newI"
665665
]
666666
},
667667
{
@@ -736,24 +736,85 @@
736736
},
737737
{
738738
"cell_type": "code",
739-
"execution_count": 61,
739+
"execution_count": 73,
740+
"metadata": {},
741+
"outputs": [],
742+
"source": [
743+
"df['S']=newI"
744+
]
745+
},
746+
{
747+
"cell_type": "code",
748+
"execution_count": 74,
740749
"metadata": {},
741750
"outputs": [
742751
{
743-
"ename": "KeyError",
744-
"evalue": "\"None of ['New_Ind'] are in the columns\"",
745-
"output_type": "error",
746-
"traceback": [
747-
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
748-
"\u001b[1;31mKeyError\u001b[0m Traceback (most recent call last)",
749-
"\u001b[1;32m<ipython-input-61-03d86a69ace3>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mdf\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mset_index\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m'New_Ind'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
750-
"\u001b[1;32m~\\Anaconda3\\lib\\site-packages\\pandas\\core\\frame.py\u001b[0m in \u001b[0;36mset_index\u001b[1;34m(self, keys, drop, append, inplace, verify_integrity)\u001b[0m\n\u001b[0;32m 4394\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 4395\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mmissing\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 4396\u001b[1;33m \u001b[1;32mraise\u001b[0m \u001b[0mKeyError\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"None of {} are in the columns\"\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mformat\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mmissing\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 4397\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 4398\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0minplace\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
751-
"\u001b[1;31mKeyError\u001b[0m: \"None of ['New_Ind'] are in the columns\""
752-
]
752+
"data": {
753+
"text/html": [
754+
"<div>\n",
755+
"<style scoped>\n",
756+
" .dataframe tbody tr th:only-of-type {\n",
757+
" vertical-align: middle;\n",
758+
" }\n",
759+
"\n",
760+
" .dataframe tbody tr th {\n",
761+
" vertical-align: top;\n",
762+
" }\n",
763+
"\n",
764+
" .dataframe thead th {\n",
765+
" text-align: right;\n",
766+
" }\n",
767+
"</style>\n",
768+
"<table border=\"1\" class=\"dataframe\">\n",
769+
" <thead>\n",
770+
" <tr style=\"text-align: right;\">\n",
771+
" <th></th>\n",
772+
" <th>X</th>\n",
773+
" <th>Y</th>\n",
774+
" <th>Z</th>\n",
775+
" <th>S</th>\n",
776+
" </tr>\n",
777+
" </thead>\n",
778+
" <tbody>\n",
779+
" <tr>\n",
780+
" <td>A</td>\n",
781+
" <td>0.925094</td>\n",
782+
" <td>0.964265</td>\n",
783+
" <td>0.463295</td>\n",
784+
" <td>A</td>\n",
785+
" </tr>\n",
786+
" <tr>\n",
787+
" <td>B</td>\n",
788+
" <td>0.806830</td>\n",
789+
" <td>0.853177</td>\n",
790+
" <td>0.381970</td>\n",
791+
" <td>B</td>\n",
792+
" </tr>\n",
793+
" <tr>\n",
794+
" <td>C</td>\n",
795+
" <td>0.369193</td>\n",
796+
" <td>0.592646</td>\n",
797+
" <td>0.820605</td>\n",
798+
" <td>C</td>\n",
799+
" </tr>\n",
800+
" </tbody>\n",
801+
"</table>\n",
802+
"</div>"
803+
],
804+
"text/plain": [
805+
" X Y Z S\n",
806+
"A 0.925094 0.964265 0.463295 A\n",
807+
"B 0.806830 0.853177 0.381970 B\n",
808+
"C 0.369193 0.592646 0.820605 C"
809+
]
810+
},
811+
"execution_count": 74,
812+
"metadata": {},
813+
"output_type": "execute_result"
753814
}
754815
],
755816
"source": [
756-
"df.set_index('New_Ind')"
817+
"df"
757818
]
758819
}
759820
],

0 commit comments

Comments
 (0)