Skip to content

Commit

Permalink
Add files via upload (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
PtPrashantTripathi authored Sep 6, 2024
1 parent 55382f8 commit 846a905
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions NOTEBOOKS/04_API_LAYER_ETL/01_API.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,22 @@
"df_dividend = pd.read_csv(dividend_gold_file_path)\n",
"print(f\"Proccessing Data : {dividend_gold_file_path}\")\n",
"\n",
"# Convert 'date' to datetime and extract year\n",
"df_dividend[\"year\"] = pd.to_datetime(df_dividend[\"date\"]).dt.year\n",
"# Convert 'date' column to datetime if not already in datetime format\n",
"df_dividend['date1'] = pd.to_datetime(df_dividend['date'])\n",
"\n",
"# Function to calculate financial year\n",
"def get_financial_year(date):\n",
" year = date.year\n",
" if date.month < 4: # If month is before April, it belongs to the previous financial year\n",
" start_year = year - 1\n",
" end_year = year\n",
" else:\n",
" start_year = year\n",
" end_year = year + 1\n",
" return f\"{start_year}-{str(end_year)[-2:]}\" # Format as 'YYYY-YY'\n",
"\n",
"# Apply the function to create the 'financial_year' column\n",
"df_dividend['year'] = df_dividend['date1'].apply(get_financial_year)\n",
"\n",
"stock_wise_dividend_data = [\n",
" {\n",
Expand Down Expand Up @@ -531,7 +545,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.4"
"version": "3.11.6"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 846a905

Please sign in to comment.