EDA
MACHAIN LEARNING
DEEP LEARNING
Tensorflow
keras
pytorch
opencv
pillow
OBJECT DETECTION MODELS TRANSFEER LErning
Mobilenet
VGGNET
Resnet
Inceptionv3
YOLO
Natural language process
NLTX
SpCy
Wordcloud
NLP WORD EMBEDDING MODELS
Word2Vec
GloVe
Fasttext
ALLEN NLP (organization)
NLP application : Pyspark as Backend
Optical Character Recognition(OCR)
Extract the text from the image
Tesseract
easyocr
BERT
BERT Bi directional Encoded Representations from Transformers
Transformers Hugging face --google
WebScrapping
SQLITE
Selenium
Beautiful soup
Regex
GenAI AND LLM
langchain
GPT
Gemini
L1AMA
Grok
BedRock
Claude AI Anthropic
AGENTIC AI
langraph
CrewAI
phidata
Autogen
API creation
Flask
FastAPI
Grdiuo
Dhango
WEBAPPLICATION
Streamlit
Model deployment
mlflow
lubeflow
Cloud AI
Azure Cognitive services
Azure ML Studio
GCP VeertexAI
AWS Sagemaker
Extra
random
time
math
logging
warnings
date
Step-1:import Packages
import numpy as np import pandas as pd
**Step 2 Create a Dataframe using List
names=['Ramesh','Suresh','Mahesh'] pd.DataFrame(names)
| 0 | |
|---|---|
| 0 | Ramesh |
| 1 | Suresh |
| 2 | Mahesh |
names=['Ramesh','Suresh','Mahesh'] age=[30,32,24] pd.DataFrame(names,age)
| 0 | |
|---|---|
| 30 | Ramesh |
| 32 | Suresh |
| 24 | Mahesh |
names=['Ramesh','Suresh','Mahesh'] age=[30,32,24] pd.DataFrame(names,age)
| 0 | |
|---|---|
| 30 | Ramesh |
| 32 | Suresh |
| 24 | Mahesh |
Step-3:Insert the column
- column balue except an Index or array like
names=['Ramesh','Suresh','Mahesh'] pd.DataFrame(names,columns=['Names'])
| Names | |
|---|---|
| 0 | Ramesh |
| 1 | Suresh |
| 2 | Mahesh |
names=['Ramesh','Suresh','Mahesh']
age=[30,32,24]
city=['hyd','mumbai','pune']
cols=['Names','Age','City']
pd.DataFrame(zip(names,age,city),
columns=cols)
| Names | Age | City | |
|---|---|---|---|
| 0 | Ramesh | 30 | hyd |
| 1 | Suresh | 32 | mumbai |
| 2 | Mahesh | 24 | pune |
Step-6: Create a DataFrame using Scalar value means using
Step-7: data quack check - shape - size - len - columns - dtypes
names=['Ramesh','Suresh','Mahesh'] age=[30,32,24] city=['hyd','mumbai','pune']
Step-8: Add data to empty dataframe
d1=pd.DataFrame()
d1['Names']=['Ramesh','Suresh','Sathish']
d1['Age']=[23,22,34]
Step-9: Add data to already Existed Dataframe
df1 already has a dara with columns Names,
Step-10: How to update the colmn values
if you want to add the nwq column to empty dataframe
if you want to ass the new column to alreday existed dataframe
if uou want to modify the data of a specific column
syntax is same
cf[coname]=[data]
Step-11: How to Drop the specific column
by default axis=0 represent
if
import pandas as pd
# Create a DataFrame
data = {'Names': ['Ramesh', 'Suresh', 'Mahesh'],
'Age': [30, 32, 24],
'City': ['hyd', 'mumbai', 'pune']}
df1 = pd.DataFrame(data)
# Print the original DataFrame
print("Original DataFrame:")
print(df1)
# Drop the 'City' column
df1.drop('City', axis=1, inplace=True)
# Print the modified DataFrame
print("\nModified DataFrame (after dropping 'City'):")
print(df1)
Original DataFrame:
Names Age City
0 Ramesh 30 hyd
1 Suresh 32 mumbai
2 Mahesh 24 pune
Modified DataFrame (after dropping 'City'):
Names Age
0 Ramesh 30
1 Suresh 32
2 Mahesh 24
import pandas as pd
d1 = pd.DataFrame()
d1['Names'] = ['Ramesh', 'Suresh', 'Sathish']
d1['Age'] = [23, 22, 34]
# Displaying the DataFrame
print(d1)
Names Age
0 Ramesh 23
1 Suresh 22
2 Sathish 34
df1
Step-12: Rename the column
create a dictionary key as old name value as new frame
dict1={"Marks":"marks"}
df1.rename(columns=dict1)
df1.rename(columns=dict1)
Names
0 Ramesh
1 Suresh
2 Mahesh
import pandas as pd
# Create a sample DataFrame
data = {'Names': ['Ramesh', 'Suresh', 'Mahesh'],
'Age': [30, 32, 24],
'City': ['hyd', 'mumbai', 'pune']}
df1 = pd.DataFrame(data)
# Print the original DataFrame
print("Original DataFrame:")
print(df1)
# Rename the columns
df1.columns = ['Name', 'Age', 'City']
# Print the modified DataFrame
print("\nModified DataFrame (after renaming columns):")
print(df1)
Original DataFrame:
Names Age City
0 Ramesh 30 hyd
1 Suresh 32 mumbai
2 Mahesh 24 pune
Modified DataFrame (after renaming columns):
Name Age City
0 Ramesh 30 hyd
1 Suresh 32 mumbai
2 Mahesh 24 pune
Step-13: Add a new row
df1
Name Age City
0 Ramesh 30 hyd
1 Suresh 32 mumbai
2 Mahesh 24 pune
import pandas as pd
# Create a DataFrame
df1 = pd.DataFrame({'Names': ['Ramesh', 'Suresh', 'Mahesh']})
# Add a new column 'Age' with values
df1['Age'] = [30, 32, 24]
# Print the updated DataFrame
print(df1)
Names Age
0 Ramesh 30
1 Suresh 32
2 Mahesh 24
df1
Names Age
0 Ramesh 30
1 Suresh 32
2 Mahesh 24
df1.to_csv('data.csv')
Step-15:Read the dataframe
import pandas as pd
# Read the CSV file into a DataFrame
df1 = pd.read_csv('data.csv')
# Print the first few rows of the DataFrame
print("DataFrame loaded from CSV:")
print(df1)
DataFrame loaded from CSV:
Unnamed: 0 Names Age
0 0 Ramesh 30
1 1 Suresh 32
2 2 Mahesh 24
df1.to_csv('data1.csv',index=False)
import pandas as pd
# Load the CSV file into a DataFrame
df1 = pd.read_csv('data1.csv')
# Print confirmation and display the DataFrame
print("DataFrame loaded from CSV:")
print(df1)
DataFrame loaded from CSV:
Names Age
0 Ramesh 30
1 Suresh 32
2 Mahesh 24
import pandas as pd
# Create a sample DataFrame
data = {'Names': ['Ramesh', 'Suresh', 'Mahesh'],
'Age': [30, 32, 24],
'City': ['Hyderabad', 'Mumbai', 'Pune']}
df1 = pd.DataFrame(data)
# Save the DataFrame to an Excel file
df1.to_excel('data1.xlsx', index=False)
print("DataFrame has been saved to 'data1.xlsx'.")
# Load the Excel file back into a DataFrame
df2 = pd.read_excel('data1.xlsx')
# Print confirmation and display the loaded DataFrame
print("\nDataFrame loaded from Excel:")
print(df2)
DataFrame has been saved to 'data1.xlsx'.
DataFrame loaded from Excel:
Names Age City
0 Ramesh 30 Hyderabad
1 Suresh 32 Mumbai
2 Mahesh 24 Pune
{
“cells”: [
{
“cell_type”: “code”,
“execution_count”: null,
“id”: “6d054607-8b9f-4bd4-8926-c4cb80c0f5f9”,
“metadata”: {},
“outputs”: [],
“source”: [
“EDA\n”,
“\n”,
“MACHAIN LEARNING\n”,
“\n”,
“DEEP LEARNING\n”,
“Tensorflow \n”,
“keras \n”,
“pytorch\n”,
“opencv\n”,
“pillow\n”,
“\n”,
“OBJECT DETECTION MODELS TRANSFEER LErning\n”,
“Mobilenet\n”,
“VGGNET\n”,
“Resnet\n”,
“Inceptionv3\n”,
“YOLO\n”,
“\n”,
“Natural language process\n”,
“NLTX\n”,
“SpCy\n”,
“Wordcloud\n”,
“\n”,
“NLP WORD EMBEDDING MODELS \n”,
“Word2Vec\n”,
“GloVe\n”,
“Fasttext\n”,
“\n”,
“ALLEN NLP (organization)\n”,
“NLP application : Pyspark as Backend \n”,
“\n”,
“Optical Character Recognition(OCR)\n”,
“Extract the text from the image \n”,
“Tesseract \n”,
“easyocr\n”,
“\n”,
“BERT\n”,
“BERT Bi directional Encoded Representations from Transformers \n”,
“Transformers Hugging face –google \n”,
“\n”,
“WebScrapping \n”,
“SQLITE \n”,
“Selenium\n”,
“Beautiful soup\n”,
“Regex\n”,
“\n”,
“GenAI AND LLM\n”,
“langchain \n”,
“GPT\n”,
“Gemini\n”,
“L1AMA\n”,
“Grok \n”,
“BedRock\n”,
“Claude AI Anthropic\n”,
“\n”,
“AGENTIC AI\n”,
“langraph\n”,
“CrewAI\n”,
“phidata\n”,
“Autogen\n”,
“\n”,
“API creation\n”,
“Flask \n”,
“FastAPI\n”,
“Grdiuo\n”,
“Dhango\n”,
“\n”,
“WEBAPPLICATION\n”,
“Streamlit \n”,
“\n”,
“Model deployment \n”,
“mlflow \n”,
“lubeflow \n”,
“\n”,
“Cloud AI\n”,
“Azure Cognitive services \n”,
“Azure ML Studio\n”,
“GCP VeertexAI\n”,
“AWS Sagemaker \n”,
“\n”,
“Extra\n”,
“random \n”,
“time \n”,
“math\n”,
“logging\n”,
“warnings \n”,
“date”
]
},
{
“cell_type”: “markdown”,
“id”: “d5930542-adc8-4963-a370-46dd0d56f37f”,
“metadata”: {},
“source”: [
“Step-1:import Packages”
]
},
{
“cell_type”: “code”,
“execution_count”: 3,
“id”: “3b9171a3-2d23-4ed7-8a48-ca4a6a335d0e”,
“metadata”: {},
“outputs”: [],
“source”: [
“import numpy as np\n”,
“import pandas as pd”
]
},
{
“cell_type”: “markdown”,
“id”: “bdad40a3-b210-48ad-a4b7-5198e359b6b2”,
“metadata”: {},
“source”: [
“Step 2 Create a Dataframe using List ” ] }, { “cell_type”: “code”, “execution_count”: 4, “id”: “99503a99-1ab7-44b5-b34c-04cfda5d11f8”, “metadata”: {}, “outputs”: [ { “data”: { “text/html”: [ “
\n”, “\n”, “\n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, “
| 0 | |
|---|---|
| 0 | Ramesh |
| 1 | Suresh |
| 2 | Mahesh |
\n”, “” ], “text/plain”: [ ” 0\n”, “0 Ramesh\n”, “1 Suresh\n”, “2 Mahesh” ] }, “execution_count”: 4, “metadata”: {}, “output_type”: “execute_result” } ], “source”: [ “names=[‘Ramesh’,’Suresh’,’Mahesh’]\n”, “pd.DataFrame(names)” ] }, { “cell_type”: “code”, “execution_count”: 6, “id”: “26a7c680-7bc8-423d-8fa7-9acaa2c4df1c”, “metadata”: {}, “outputs”: [ { “data”: { “text/html”: [ “
\n”, “\n”, “\n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, “
| 0 | |
|---|---|
| 30 | Ramesh |
| 32 | Suresh |
| 24 | Mahesh |
\n”, “” ], “text/plain”: [ ” 0\n”, “30 Ramesh\n”, “32 Suresh\n”, “24 Mahesh” ] }, “execution_count”: 6, “metadata”: {}, “output_type”: “execute_result” } ], “source”: [ “names=[‘Ramesh’,’Suresh’,’Mahesh’]\n”, “age=[30,32,24]\n”, “pd.DataFrame(names,age)” ] }, { “cell_type”: “code”, “execution_count”: 8, “id”: “b6fdcec5-b32a-40a3-a3af-16583cc7864c”, “metadata”: {}, “outputs”: [ { “data”: { “text/html”: [ “
\n”, “\n”, “\n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, “
| 0 | |
|---|---|
| 30 | Ramesh |
| 32 | Suresh |
| 24 | Mahesh |
\n”, “” ], “text/plain”: [ ” 0\n”, “30 Ramesh\n”, “32 Suresh\n”, “24 Mahesh” ] }, “execution_count”: 8, “metadata”: {}, “output_type”: “execute_result” } ], “source”: [ “names=[‘Ramesh’,’Suresh’,’Mahesh’]\n”, “age=[30,32,24]\n”, “pd.DataFrame(names,age)” ] }, { “cell_type”: “markdown”, “id”: “b214421d-bdbf-4b21-8347-26cc5d1cef85”, “metadata”: {}, “source”: [ “Step-3:Insert the column” ] }, { “cell_type”: “markdown”, “id”: “9c8cc958-d404-463f-abcb-caf78296af23”, “metadata”: {}, “source”: [ “- column balue except an Index or array like ” ] }, { “cell_type”: “code”, “execution_count”: 12, “id”: “fbb35af3-9312-4a77-90e8-731b1c9024de”, “metadata”: {}, “outputs”: [ { “data”: { “text/html”: [ “
\n”, “\n”, “\n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, “
| Names | |
|---|---|
| 0 | Ramesh |
| 1 | Suresh |
| 2 | Mahesh |
\n”, “” ], “text/plain”: [ ” Names\n”, “0 Ramesh\n”, “1 Suresh\n”, “2 Mahesh” ] }, “execution_count”: 12, “metadata”: {}, “output_type”: “execute_result” } ], “source”: [ “names=[‘Ramesh’,’Suresh’,’Mahesh’]\n”, “pd.DataFrame(names,columns=[‘Names’])” ] }, { “cell_type”: “code”, “execution_count”: 9, “id”: “1bad1a91-01b6-4a8b-b8d2-29a031d74215”, “metadata”: {}, “outputs”: [ { “data”: { “text/html”: [ “
\n”, “\n”, “\n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, “
| Names | Age | City | |
|---|---|---|---|
| 0 | Ramesh | 30 | hyd |
| 1 | Suresh | 32 | mumbai |
| 2 | Mahesh | 24 | pune |
\n”, “” ], “text/plain”: [ ” Names Age City\n”, “0 Ramesh 30 hyd\n”, “1 Suresh 32 mumbai\n”, “2 Mahesh 24 pune” ] }, “execution_count”: 9, “metadata”: {}, “output_type”: “execute_result” } ], “source”: [ “names=[‘Ramesh’,’Suresh’,’Mahesh’]\n”, “age=[30,32,24]\n”, “city=[‘hyd’,’mumbai’,’pune’]\n”, “cols=[‘Names’,’Age’,’City’]\n”, “pd.DataFrame(zip(names,age,city),\n”, ” columns=cols)” ] }, { “cell_type”: “markdown”, “id”: “3a0335d5-4435-439a-8150-5a60a3ef9e86”, “metadata”: {}, “source”: [ “Step-6: Create a DataFrame using Scalar value means using ” ] }, { “cell_type”: “code”, “execution_count”: null, “id”: “f8bdaa62-31fb-4c06-a5f3-cb9e8fcbd2b1”, “metadata”: {}, “outputs”: [], “source”: [ “Step-7: data quack check\n”, “- shape \n”, “- size \n”, “- len \n”, “- columns \n”, “- dtypes” ] }, { “cell_type”: “code”, “execution_count”: 13, “id”: “f3be54ee-41b4-435d-836d-dec7707316f6”, “metadata”: {}, “outputs”: [], “source”: [ “names=[‘Ramesh’,’Suresh’,’Mahesh’]\n”, “age=[30,32,24]\n”, “city=[‘hyd’,’mumbai’,’pune’]” ] }, { “cell_type”: “markdown”, “id”: “e186db1b-fa01-435a-ad6f-cad5db7d13df”, “metadata”: {}, “source”: [ “Step-8: Add data to empty dataframe” ] }, { “cell_type”: “code”, “execution_count”: 15, “id”: “07f9561a-4a1e-41fb-bbee-8994e25aeccf”, “metadata”: {}, “outputs”: [], “source”: [ “d1=pd.DataFrame()\n”, “d1[‘Names’]=[‘Ramesh’,’Suresh’,’Sathish’]\n”, “d1[‘Age’]=[23,22,34]” ] }, { “cell_type”: “markdown”, “id”: “29d92aa5-d518-4679-a48e-2405cc23f625”, “metadata”: {}, “source”: [ “Step-9: Add data to already Existed Dataframe\n”, “- df1 already has a dara with columns Names,” ] }, { “cell_type”: “markdown”, “id”: “486d1e17-d121-4010-acb6-f396f7668ada”, “metadata”: {}, “source”: [ “Step-10: How to update the colmn values\n”, “- if you want to add the nwq column to empty dataframe \n”, “- if you want to ass the new column to alreday existed dataframe \n”, “- if uou want to modify the data of a specific column \n”, “- syntax is same \n”, “- cf[coname]=[data]” ] }, { “cell_type”: “markdown”, “id”: “2f5fd703-efc2-4ca9-833f-bf1e51cdefea”, “metadata”: {}, “source”: [ “Step-11: How to Drop the specific column\n”, “- by default axis=0 represent\n”, “- if ” ] }, { “cell_type”: “code”, “execution_count”: 20, “id”: “aff54cf9-785b-4da6-b221-cb714b56364d”, “metadata”: {}, “outputs”: [ { “name”: “stdout”, “output_type”: “stream”, “text”: [ “Original DataFrame:\n”, ” Names Age City\n”, “0 Ramesh 30 hyd\n”, “1 Suresh 32 mumbai\n”, “2 Mahesh 24 pune\n”, “\n”, “Modified DataFrame (after dropping ‘City’):\n”, ” Names Age\n”, “0 Ramesh 30\n”, “1 Suresh 32\n”, “2 Mahesh 24\n” ] } ], “source”: [ “import pandas as pd\n”, “\n”, “# Create a DataFrame\n”, “data = {‘Names’: [‘Ramesh’, ‘Suresh’, ‘Mahesh’],\n”, ” ‘Age’: [30, 32, 24],\n”, ” ‘City’: [‘hyd’, ‘mumbai’, ‘pune’]}\n”, “\n”, “df1 = pd.DataFrame(data)\n”, “\n”, “# Print the original DataFrame\n”, “print(\”Original DataFrame:\”)\n”, “print(df1)\n”, “\n”, “# Drop the ‘City’ column\n”, “df1.drop(‘City’, axis=1, inplace=True)\n”, “\n”, “# Print the modified DataFrame\n”, “print(\”\nModified DataFrame (after dropping ‘City’):\”)\n”, “print(df1)” ] }, { “cell_type”: “code”, “execution_count”: 18, “id”: “7cf35d85-9e04-4067-9260-3437af3c7e00”, “metadata”: {}, “outputs”: [ { “name”: “stdout”, “output_type”: “stream”, “text”: [ ” Names Age\n”, “0 Ramesh 23\n”, “1 Suresh 22\n”, “2 Sathish 34\n” ] } ], “source”: [ “import pandas as pd\n”, “\n”, “d1 = pd.DataFrame()\n”, “d1[‘Names’] = [‘Ramesh’, ‘Suresh’, ‘Sathish’]\n”, “d1[‘Age’] = [23, 22, 34]\n”, “\n”, “# Displaying the DataFrame\n”, “print(d1)” ] }, { “cell_type”: “code”, “execution_count”: null, “id”: “777e9ee9-ce5f-47a0-9ad4-4616af689955”, “metadata”: {}, “outputs”: [], “source”: [ “df1” ] }, { “cell_type”: “markdown”, “id”: “a106f867-7d60-4cdb-8161-2566b732a946”, “metadata”: {}, “source”: [ “Step-12: Rename the column\n”, “- create a dictionary key as old name value as new frame ” ] }, { “cell_type”: “code”, “execution_count”: 23, “id”: “15e994b2-4470-4fa4-b0fc-98f33ac20152”, “metadata”: {}, “outputs”: [ { “data”: { “text/html”: [ “
\n”, “\n”, “\n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, “
| Names | |
|---|---|
| 0 | Ramesh |
| 1 | Suresh |
| 2 | Mahesh |
\n”, “” ], “text/plain”: [ ” Names\n”, “0 Ramesh\n”, “1 Suresh\n”, “2 Mahesh” ] }, “execution_count”: 23, “metadata”: {}, “output_type”: “execute_result” } ], “source”: [ “dict1={\”Marks\”:\”marks\”}\n”, “df1.rename(columns=dict1)” ] }, { “cell_type”: “code”, “execution_count”: 27, “id”: “f04ce1cf-65f1-40c5-a05b-32ed0ab89ec7”, “metadata”: {}, “outputs”: [ { “name”: “stdout”, “output_type”: “stream”, “text”: [ “Original DataFrame:\n”, ” Names Age City\n”, “0 Ramesh 30 hyd\n”, “1 Suresh 32 mumbai\n”, “2 Mahesh 24 pune\n”, “\n”, “Modified DataFrame (after renaming columns):\n”, ” Name Age City\n”, “0 Ramesh 30 hyd\n”, “1 Suresh 32 mumbai\n”, “2 Mahesh 24 pune\n” ] } ], “source”: [ “import pandas as pd\n”, “\n”, “# Create a sample DataFrame\n”, “data = {‘Names’: [‘Ramesh’, ‘Suresh’, ‘Mahesh’],\n”, ” ‘Age’: [30, 32, 24],\n”, ” ‘City’: [‘hyd’, ‘mumbai’, ‘pune’]}\n”, “\n”, “df1 = pd.DataFrame(data)\n”, “\n”, “# Print the original DataFrame\n”, “print(\”Original DataFrame:\”)\n”, “print(df1)\n”, “\n”, “# Rename the columns\n”, “df1.columns = [‘Name’, ‘Age’, ‘City’]\n”, “\n”, “# Print the modified DataFrame\n”, “print(\”\nModified DataFrame (after renaming columns):\”)\n”, “print(df1)” ] }, { “cell_type”: “markdown”, “id”: “a7fc1aa9-e276-4c17-ae92-8cbd2cbeb891”, “metadata”: {}, “source”: [ “Step-13: Add a new row” ] }, { “cell_type”: “code”, “execution_count”: 28, “id”: “5efe80c1-9636-475b-b43c-6602deca1955”, “metadata”: {}, “outputs”: [ { “data”: { “text/html”: [ “
\n”, “\n”, “\n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, “
| Name | Age | City | |
|---|---|---|---|
| 0 | Ramesh | 30 | hyd |
| 1 | Suresh | 32 | mumbai |
| 2 | Mahesh | 24 | pune |
\n”, “” ], “text/plain”: [ ” Name Age City\n”, “0 Ramesh 30 hyd\n”, “1 Suresh 32 mumbai\n”, “2 Mahesh 24 pune” ] }, “execution_count”: 28, “metadata”: {}, “output_type”: “execute_result” } ], “source”: [ “df1” ] }, { “cell_type”: “code”, “execution_count”: 31, “id”: “0a3ec460-7b97-471a-80e5-6bc9bbf6f1ef”, “metadata”: {}, “outputs”: [ { “name”: “stdout”, “output_type”: “stream”, “text”: [ ” Names Age\n”, “0 Ramesh 30\n”, “1 Suresh 32\n”, “2 Mahesh 24\n” ] } ], “source”: [ “import pandas as pd\n”, “\n”, “# Create a DataFrame\n”, “df1 = pd.DataFrame({‘Names’: [‘Ramesh’, ‘Suresh’, ‘Mahesh’]})\n”, “\n”, “# Add a new column ‘Age’ with values\n”, “df1[‘Age’] = [30, 32, 24]\n”, “\n”, “# Print the updated DataFrame\n”, “print(df1)” ] }, { “cell_type”: “code”, “execution_count”: 32, “id”: “25f5b1eb-1cd5-48e2-88ab-63fc6cdd0620”, “metadata”: {}, “outputs”: [ { “data”: { “text/html”: [ “
\n”, “\n”, “\n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, ” \n”, “
| Names | Age | |
|---|---|---|
| 0 | Ramesh | 30 |
| 1 | Suresh | 32 |
| 2 | Mahesh | 24 |
\n”, “” ], “text/plain”: [ ” Names Age\n”, “0 Ramesh 30\n”, “1 Suresh 32\n”, “2 Mahesh 24” ] }, “execution_count”: 32, “metadata”: {}, “output_type”: “execute_result” } ], “source”: [ “df1” ] }, { “cell_type”: “code”, “execution_count”: 35, “id”: “1e96bdce-2c8d-4a23-ac49-a46bc2f00910”, “metadata”: {}, “outputs”: [], “source”: [ “df1.to_csv(‘data.csv’)” ] }, { “cell_type”: “markdown”, “id”: “b4983cd6-5ebd-4d2a-83ef-1118439ab130”, “metadata”: {}, “source”: [ “Step-15:Read the dataframe** “
]
},
{
“cell_type”: “code”,
“execution_count”: 39,
“id”: “aecd4ec8-3845-4507-b5d3-6a97e5b1f271”,
“metadata”: {},
“outputs”: [
{
“name”: “stdout”,
“output_type”: “stream”,
“text”: [
“DataFrame loaded from CSV:\n”,
” Unnamed: 0 Names Age\n”,
“0 0 Ramesh 30\n”,
“1 1 Suresh 32\n”,
“2 2 Mahesh 24\n”
]
}
],
“source”: [
“import pandas as pd\n”,
“\n”,
“# Read the CSV file into a DataFrame\n”,
“df1 = pd.read_csv(‘data.csv’)\n”,
“\n”,
“# Print the first few rows of the DataFrame\n”,
“print(\”DataFrame loaded from CSV:\”)\n”,
“print(df1)”
]
},
{
“cell_type”: “code”,
“execution_count”: 38,
“id”: “93ffa5d4-b73b-4885-8ffa-1b170a04bd5f”,
“metadata”: {},
“outputs”: [],
“source”: [
“df1.to_csv(‘data1.csv’,index=False)”
]
},
{
“cell_type”: “code”,
“execution_count”: 42,
“id”: “fe95011c-d13f-44bd-9c65-dad268897ba8”,
“metadata”: {},
“outputs”: [
{
“name”: “stdout”,
“output_type”: “stream”,
“text”: [
“DataFrame loaded from CSV:\n”,
” Names Age\n”,
“0 Ramesh 30\n”,
“1 Suresh 32\n”,
“2 Mahesh 24\n”
]
}
],
“source”: [
“import pandas as pd\n”,
“\n”,
“# Load the CSV file into a DataFrame\n”,
“df1 = pd.read_csv(‘data1.csv’)\n”,
“\n”,
“# Print confirmation and display the DataFrame\n”,
“print(\”DataFrame loaded from CSV:\”)\n”,
“print(df1)”
]
},
{
“cell_type”: “code”,
“execution_count”: 45,
“id”: “e54b33fb-bd77-4a19-b6b3-6e0848d08596”,
“metadata”: {},
“outputs”: [
{
“name”: “stdout”,
“output_type”: “stream”,
“text”: [
“DataFrame has been saved to ‘data1.xlsx’.\n”,
“\n”,
“DataFrame loaded from Excel:\n”,
” Names Age City\n”,
“0 Ramesh 30 Hyderabad\n”,
“1 Suresh 32 Mumbai\n”,
“2 Mahesh 24 Pune\n”
]
}
],
“source”: [
“\n”,
“import pandas as pd\n”,
“\n”,
“# Create a sample DataFrame\n”,
“data = {‘Names’: [‘Ramesh’, ‘Suresh’, ‘Mahesh’],\n”,
” ‘Age’: [30, 32, 24],\n”,
” ‘City’: [‘Hyderabad’, ‘Mumbai’, ‘Pune’]}\n”,
“\n”,
“df1 = pd.DataFrame(data)\n”,
“\n”,
“# Save the DataFrame to an Excel file\n”,
“df1.to_excel(‘data1.xlsx’, index=False)\n”,
“print(\”DataFrame has been saved to ‘data1.xlsx’.\”)\n”,
“\n”,
“# Load the Excel file back into a DataFrame\n”,
“df2 = pd.read_excel(‘data1.xlsx’)\n”,
“\n”,
“# Print confirmation and display the loaded DataFrame\n”,
“print(\”\nDataFrame loaded from Excel:\”)\n”,
“print(df2)”
]
}
],
“metadata”: {
“kernelspec”: {
“display_name”: “Python 3 (ipykernel)”,
“language”: “python”,
“name”: “python3”
},
“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.12.7”
}
},
“nbformat”: 4,
“nbformat_minor”: 5
}