Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 3

{

"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "incoming-delight",
"metadata": {},
"outputs": [],
"source": [
"# Import required library\n",
"\n",
"import pandas as pd"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "manufactured-anderson",
"metadata": {},
"outputs": [],
"source": [
"# di laptop saya folder tutorial1 ini berada di dalam folder jupyterproject\
n",
"# letakkan folder data dan file panda.ipynb dalam satu folder tutorial1\n",
"\n",
"fileLocation = '../tutorial1/data/table1APK.xlsx'\n",
"df = pd.read_excel(fileLocation)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "russian-healing",
"metadata": {},
"outputs": [],
"source": [
"# melihat sebagian data\n",
"\n",
"df.head()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "lesbian-liabilities",
"metadata": {},
"outputs": [],
"source": [
"fileLocation = '../tutorial1/data/table2Kredit.csv'\n",
"df2 = pd.read_csv(fileLocation)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "convenient-stroke",
"metadata": {},
"outputs": [],
"source": [
"# melihat sebagian data\n",
"\n",
"df2.head()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "first-ottawa",
"metadata": {},
"outputs": [],
"source": [
"# mengambil data baris 0-2 dan kolom Usaha sampai tahun 2013\n",
"\n",
"z=df2.loc[0:2,'Usaha':'2013']\n",
"z"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "engaged-hebrew",
"metadata": {},
"outputs": [],
"source": [
"# mengambil data baris 0-2 dan kolom Usaha sampai tahun 2013\n",
"\n",
"z=df2.iloc[0:3,0:4]\n",
"z"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "focal-despite",
"metadata": {},
"outputs": [],
"source": [
"# Access to the column as series\n",
"\n",
"x = df2['Usaha']\n",
"x"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "parallel-reliance",
"metadata": {},
"outputs": [],
"source": [
"# Get the column as a dataframe\n",
"\n",
"x = df2[['Usaha']]\n",
"x"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "clinical-seven",
"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.8.8"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

You might also like