Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
206 changes: 206 additions & 0 deletions practice/PD1.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 5,
"id": "681405ed",
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "4320e7b8",
"metadata": {},
"outputs": [],
"source": [
"\"\"\"\n",
"#DataFrame:\n",
" main data struct in Pandas\n",
" a table w/many funcs.\n",
"\n",
"\"\"\"\n",
"\n",
"df=pd.DataFrame([[1,2,3],\n",
" [4,5,6],\n",
" [7,8,9]], \n",
" columns=[\"A\", \"B\", \"C\"],#Adds labels to the columns\n",
" index=[\"a\", \"b\", \"c\"]) #labels to rows"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "6f9159ef",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" A B C\n",
"a 1 2 3\n",
"b 4 5 6\n",
"c 7 8 9\n"
]
}
],
"source": [
"print(df.head())#first five rows (here there are only three)\n",
"\n",
"\"\"\"\n",
"Outout w/o columns & indices defnd.:\n",
" 0 1 2\n",
"0 1 2 3\n",
"1 4 5 6\n",
"2 7 8 9\n",
"\n",
"Outout w/columns defnd.:\n",
" A B C\n",
"0 1 2 3\n",
"1 4 5 6\n",
"2 7 8 9\n",
"\n",
"Outout w/indices defnd.:\n",
" A B C\n",
"a 1 2 3\n",
"b 4 5 6\n",
"c 7 8 9\n",
"\n",
"\"\"\""
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "f34c9950",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"<class 'pandas.core.frame.DataFrame'>\n",
"Index: 3 entries, a to c\n",
"Data columns (total 3 columns):\n",
" # Column Non-Null Count Dtype\n",
"--- ------ -------------- -----\n",
" 0 A 3 non-null int64\n",
" 1 B 3 non-null int64\n",
" 2 C 3 non-null int64\n",
"dtypes: int64(3)\n",
"memory usage: 96.0+ bytes\n",
"None\n"
]
}
],
"source": [
"print(df.info())"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "0a140f8c",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
" A B C\n",
"count 3.0 3.0 3.0\n",
"mean 4.0 5.0 6.0\n",
"std 3.0 3.0 3.0\n",
"min 1.0 2.0 3.0\n",
"25% 2.5 3.5 4.5\n",
"50% 4.0 5.0 6.0\n",
"75% 5.5 6.5 7.5\n",
"max 7.0 8.0 9.0\n"
]
}
],
"source": [
"print(f\"\\n{df.describe()}\")"
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "905150e7",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"A 3\n",
"B 3\n",
"C 3\n",
"dtype: int64\n",
"\n",
"3\n"
]
}
],
"source": [
"print(df.nunique())#entire DF\n",
"print(f\"\\n{df[\"A\"].nunique()}\")#partclr col"
]
},
{
"cell_type": "code",
"execution_count": 16,
"id": "42e927bf",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(3, 3)"
]
},
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.shape"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "78326e0f",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.13.5"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Loading