Created
April 8, 2021 18:44
-
-
Save PANDATD/bac58fbe437e5d8e60576559e464b7df to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "cells": [ | |
| { | |
| "cell_type": "markdown", | |
| "metadata": {}, | |
| "source": [ | |
| "# Importing pandas module " | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 5, | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "import pandas as pd \n", | |
| "# keyword module_name as alias" | |
| ] | |
| }, | |
| { | |
| "cell_type": "markdown", | |
| "metadata": {}, | |
| "source": [ | |
| "- Creating Data Frame from Dictionary \n", | |
| "- This is easy any eficient way to create data frame " | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 6, | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "users ={\n", | |
| " 'Name':['Tejas', 'Vignesh', 'Yashraj'],\n", | |
| " 'Fav-subjects':[('Data-scince','python','linux'),('WebDevlopment','hacking','machine-learinng'),\n", | |
| " ('Digital Electronics','drone-manufacturing','wireless communication')],\n", | |
| " 'Age':[19,19,19]\n", | |
| "}" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 7, | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/plain": [ | |
| "\"Dict of users {'Name': ['Tejas', 'Vignesh', 'Yashraj'], 'Fav-subjects': [('Data-scince', 'python', 'linux'), ('WebDevlopment', 'hacking', 'machine-learinng'), ('Digital Electronics', 'drone-manufacturing', 'wireless communication')], 'Age': [19, 19, 19]} \"" | |
| ] | |
| }, | |
| "execution_count": 7, | |
| "metadata": {}, | |
| "output_type": "execute_result" | |
| } | |
| ], | |
| "source": [ | |
| "f\"Dict of users {users} \"" | |
| ] | |
| }, | |
| { | |
| "cell_type": "markdown", | |
| "metadata": {}, | |
| "source": [ | |
| "#### Syntax\n", | |
| "- *dataframeobject = pd.DataFrame(dict_name)*" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 8, | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "df = pd.DataFrame(users)" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 10, | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/html": [ | |
| "<div>\n", | |
| "<style scoped>\n", | |
| " .dataframe tbody tr th:only-of-type {\n", | |
| " vertical-align: middle;\n", | |
| " }\n", | |
| "\n", | |
| " .dataframe tbody tr th {\n", | |
| " vertical-align: top;\n", | |
| " }\n", | |
| "\n", | |
| " .dataframe thead th {\n", | |
| " text-align: right;\n", | |
| " }\n", | |
| "</style>\n", | |
| "<table border=\"1\" class=\"dataframe\">\n", | |
| " <thead>\n", | |
| " <tr style=\"text-align: right;\">\n", | |
| " <th></th>\n", | |
| " <th>Name</th>\n", | |
| " <th>Fav-subjects</th>\n", | |
| " <th>Age</th>\n", | |
| " </tr>\n", | |
| " </thead>\n", | |
| " <tbody>\n", | |
| " <tr>\n", | |
| " <th>0</th>\n", | |
| " <td>Tejas</td>\n", | |
| " <td>(Data-scince, python, linux)</td>\n", | |
| " <td>19</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>1</th>\n", | |
| " <td>Vignesh</td>\n", | |
| " <td>(WebDevlopment, hacking, machine-learinng)</td>\n", | |
| " <td>19</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>2</th>\n", | |
| " <td>Yashraj</td>\n", | |
| " <td>(Digital Electronics, drone-manufacturing, wir...</td>\n", | |
| " <td>19</td>\n", | |
| " </tr>\n", | |
| " </tbody>\n", | |
| "</table>\n", | |
| "</div>" | |
| ], | |
| "text/plain": [ | |
| " Name Fav-subjects Age\n", | |
| "0 Tejas (Data-scince, python, linux) 19\n", | |
| "1 Vignesh (WebDevlopment, hacking, machine-learinng) 19\n", | |
| "2 Yashraj (Digital Electronics, drone-manufacturing, wir... 19" | |
| ] | |
| }, | |
| "execution_count": 10, | |
| "metadata": {}, | |
| "output_type": "execute_result" | |
| } | |
| ], | |
| "source": [ | |
| "df" | |
| ] | |
| }, | |
| { | |
| "cell_type": "markdown", | |
| "metadata": {}, | |
| "source": [ | |
| "### Adding new columns in data frame \n", | |
| " " | |
| ] | |
| }, | |
| { | |
| "cell_type": "markdown", | |
| "metadata": {}, | |
| "source": [ | |
| "- Syntax : DataFrameObject = ['new_column_name'] =[list of Data] " | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 11, | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "df['Os_used'] = [['Ubuntu','Fedora workstetion 33','Pop! os'],\n", | |
| " ['Kali-linux', 'Windows-10','Parrot-sec'],\n", | |
| " 'Windows-10'\n", | |
| " ]" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 12, | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/html": [ | |
| "<div>\n", | |
| "<style scoped>\n", | |
| " .dataframe tbody tr th:only-of-type {\n", | |
| " vertical-align: middle;\n", | |
| " }\n", | |
| "\n", | |
| " .dataframe tbody tr th {\n", | |
| " vertical-align: top;\n", | |
| " }\n", | |
| "\n", | |
| " .dataframe thead th {\n", | |
| " text-align: right;\n", | |
| " }\n", | |
| "</style>\n", | |
| "<table border=\"1\" class=\"dataframe\">\n", | |
| " <thead>\n", | |
| " <tr style=\"text-align: right;\">\n", | |
| " <th></th>\n", | |
| " <th>Name</th>\n", | |
| " <th>Fav-subjects</th>\n", | |
| " <th>Age</th>\n", | |
| " <th>Os_used</th>\n", | |
| " </tr>\n", | |
| " </thead>\n", | |
| " <tbody>\n", | |
| " <tr>\n", | |
| " <th>0</th>\n", | |
| " <td>Tejas</td>\n", | |
| " <td>(Data-scince, python, linux)</td>\n", | |
| " <td>19</td>\n", | |
| " <td>[Ubuntu, Fedora workstetion 33, Pop! os]</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>1</th>\n", | |
| " <td>Vignesh</td>\n", | |
| " <td>(WebDevlopment, hacking, machine-learinng)</td>\n", | |
| " <td>19</td>\n", | |
| " <td>[Kali-linux, Windows-10, Parrot-sec]</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>2</th>\n", | |
| " <td>Yashraj</td>\n", | |
| " <td>(Digital Electronics, drone-manufacturing, wir...</td>\n", | |
| " <td>19</td>\n", | |
| " <td>Windows-10</td>\n", | |
| " </tr>\n", | |
| " </tbody>\n", | |
| "</table>\n", | |
| "</div>" | |
| ], | |
| "text/plain": [ | |
| " Name Fav-subjects Age \\\n", | |
| "0 Tejas (Data-scince, python, linux) 19 \n", | |
| "1 Vignesh (WebDevlopment, hacking, machine-learinng) 19 \n", | |
| "2 Yashraj (Digital Electronics, drone-manufacturing, wir... 19 \n", | |
| "\n", | |
| " Os_used \n", | |
| "0 [Ubuntu, Fedora workstetion 33, Pop! os] \n", | |
| "1 [Kali-linux, Windows-10, Parrot-sec] \n", | |
| "2 Windows-10 " | |
| ] | |
| }, | |
| "execution_count": 12, | |
| "metadata": {}, | |
| "output_type": "execute_result" | |
| } | |
| ], | |
| "source": [ | |
| "df" | |
| ] | |
| } | |
| ], | |
| "metadata": { | |
| "kernelspec": { | |
| "display_name": "Python 3.8.6 64-bit", | |
| "language": "python", | |
| "name": "python38664bit4822670b26e8438dbb2f63c7f38ab160" | |
| }, | |
| "language_info": { | |
| "codemirror_mode": { | |
| "name": "ipython", | |
| "version": 3 | |
| }, | |
| "file_extension": ".py", | |
| "mimetype": "text/x-python", | |
| "name": "python", | |
| "nbconvert_exporter": "python", | |
| "pygments_lexer": "ipython3", | |
| "version": "3.8.6" | |
| } | |
| }, | |
| "nbformat": 4, | |
| "nbformat_minor": 4 | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment