본문 바로가기
카테고리 없음

법인카드 관리 pandas prompt

by 비즈지니 2025. 6. 25.
반응형

{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "132b3b06-1be9-4b90-a535-ad239e32ba51",
   "metadata": {},
   "source": [
    "### 연말정산과 비용처리를 위해 법인카드 사용내역을 정리해야 한다면?\n",
    "\n",
    "```\n",
    "카드 사용내역 월별 저장 : 회사는 직원들이 법인카드를 사용하여 다양한 비용(여행비, 식비, 장비 구입 등)을 지출합니다.\n",
    "연말이 다가오면서 재무팀은 모든 법인카드 사용내역을 정리하고,\n",
    "각 비용을 적절한 카테고리에 분류하여 연말정산 및 비용처리를 진행해야 합니다.\n",
    "```\n",
    "* pandas 공식 문서 : https://pandas.pydata.org/\n",
    "* pandas cheat sheet : [Pandas\\_Cheat\\_Sheet.pdf](https://pandas.pydata.org/Pandas_Cheat_Sheet.pdf)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8df337c4-22ea-472c-a945-22e36e5ceb5f",
   "metadata": {},
   "outputs": [],
   "source": [
    "# !pip install -q pandas openpyxl"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f6a09f40-0ca0-40e2-856f-987108f4f96d",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "f22cedc9-6289-43c3-a9b0-83e4453c7453",
   "metadata": {},
   "source": [
    "* pandas 의 read_html 로 html 문서 불러오기\n",
    "\n",
    "<img src=\"https://pandas.pydata.org/docs/_images/02_io_readwrite.svg\">\n",
    "\n",
    "* https://pandas.pydata.org/docs/getting_started/intro_tutorials/02_read_write.html#min-tut-02-read-write"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "856a6e81-c196-4323-accd-227eed168c45",
   "metadata": {},
   "outputs": [],
   "source": [
    "file_name = \"data/card_use.csv\"\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6eee11be-21bb-4156-9d47-4a8386f2f5e4",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "885e6162-dc01-40af-877c-ea8704750311",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f042fbc9-f544-4917-aa7f-482ab25ed603",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "28b71eff-2d8d-4e99-a20b-0a8c22d8b6b8",
   "metadata": {},
   "source": [
    "### 법인카드 사용내역 정리를 위한 회계 계정과목 매핑\n",
    "\n",
    "* 가맹점명을 통한 계정과목을 구해주세요.\n",
    "   \n",
    "```python\n",
    "# 계정과목 사전\n",
    "category_dict = {\n",
    "    '여비교통비': ['주유소', '교통', '호텔'],\n",
    "    '복리후생비': ['식당', '음식점'],\n",
    "    '소모품비': ['쿠팡', '마트', '편의점']\n",
    "}\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5f79e9c3-0755-453f-988b-6e795d625c84",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "73c9448d-db09-4f23-823a-3658e87befed",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "f5d31b0d-b0b6-4ae9-90fe-aafd70ce2207",
   "metadata": {},
   "source": [
    "* 실습에 사용한 Prompt : \n",
    "\n",
    "\n",
    "```\n",
    "<class 'pandas.core.frame.DataFrame'>\n",
    "RangeIndex: 12000 entries, 0 to 11999\n",
    "Data columns (total 4 columns):\n",
    " #   Column  Non-Null Count  Dtype \n",
    "---  ------  --------------  ----- \n",
    " 0   승인일자    12000 non-null  object\n",
    " 1   카드사     12000 non-null  object\n",
    " 2   가맹점명    12000 non-null  object\n",
    " 3   결제금액    12000 non-null  int64 \n",
    "dtypes: int64(1), object(3)\n",
    "memory usage: 375.1+ KB\n",
    "\n",
    "위와 같은 데이터프레임 정보가 df 라는 변수에 있을 때 가맹점명 컬럼을 바탕으로 계정과목을 생성하는 코드를 작성해 주세요. 계정과목은 다음 정보를 참고해 주세요.\n",
    "\n",
    "# 계정과목 사전\n",
    "category_dict = {\n",
    "    '여비교통비': ['주유소', '교통', '호텔'],\n",
    "    '복리후생비': ['식당', '음식점'],\n",
    "    '소모품비': ['쿠팡', '마트', '편의점']\n",
    "}\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "56ef9c7d-e90b-4ea3-9e48-4b02359c4add",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8d8af02b-616f-44b7-a17c-038336c74a36",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f598269a-7545-4c3c-8bb8-c9c4fe2dbb3f",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "4e0bc075-0e7e-46f8-a04f-4a6dbd958610",
   "metadata": {},
   "source": [
    "### 월별 데이터 그룹화 및 저장, 여러 시트 병합 및 데이터 정리"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b414713b-8a30-4005-b571-bf7c7991e6bb",
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "# 엑셀 파일 경로\n",
    "file_path = \"data/card-use-monthly.xlsx\"\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b00e928f-5937-43dd-bc34-e251a521061f",
   "metadata": {},
   "source": [
    "prompt : 월별로 데이터를 나누어 각각의 시트에 저장하는 엑셀 파일을 생성하는 코드를 작성하겠습니다. 각 시트에는 해당 월의 데이터만 저장되도록 하며, 저장 후 파일을 읽어 각 시트에 데이터가 잘 저장되었는지 확인하는 코드도 포함합니다.\n",
    "월별로 1월부터 12월까지 시트가 순서대로 생성될 수 있게 코드를 다시 작성해 주세요.\n",
    "xlsxwriter 대신 다른 engine 을 사용하도록 작성해 주세요."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7f44f5e4-c716-4246-90be-5a8dc0092c37",
   "metadata": {},
   "outputs": [],
   "source": [
    "# !pip install openpyxl"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2b985ad8-0eba-4026-9eb1-996ac96b93eb",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 엑셀 파일에서 모든 시트를 읽어와서 하나의 데이터 프레임으로 결합하고 하나의 데이터프레임으로 불러오기\n",
    "\n",
    "\n",
    "# 모든 시트를 읽어와서 하나의 데이터프레임으로 결합\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a0205653-4845-412a-97a1-79cabeb0f45e",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ed4330fb-43b0-4d15-9c59-94935be33197",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "e103a186-b066-4c66-acbc-0cebdec026f3",
   "metadata": {},
   "source": [
    "prompt : 엑셀 파일에서 모든 시트를 읽어와서 하나의 데이터 프레임으로 결합하고 하나의 데이터프레임으로 불러오는 코드를 작성하고 하나의 시트로 되어 있는 엑셀 파일로 저장하는 코드 작성\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "83eee83c-6a5e-459d-8060-28a6d49b756d",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "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.11.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}

반응형