Skip to content

Commit

Permalink
chore: 🎨 format source codes
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewDongminYoo committed May 5, 2024
1 parent 05f207e commit c33f84e
Show file tree
Hide file tree
Showing 9 changed files with 169 additions and 140 deletions.
6 changes: 3 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -830,13 +830,13 @@
"zeronsoftn",
"zerontech",
"zipfund",
"zixdacx",
"zixdacx"
],
"python.formatting.provider": "black",
"conventionalCommits.scopes": [
"serverless",
"python",
"typescript",
"documents",
],
"documents"
]
}
2 changes: 1 addition & 1 deletion circle-chart/event.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
"detail": {
"ip": "121.131.178.122"
}
}
}
98 changes: 61 additions & 37 deletions circle-chart/merge_circle_chart_data.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
"metadata": {},
"outputs": [],
"source": [
"CHART_PATH = './data/gaon_chart_all.csv'\n",
"PRODUCER_PATH = './data/producer_all.csv'\n",
"OUTPUT_PATH = './data/gaon_chart_all_cleanup.xlsx'"
"CHART_PATH = \"./data/gaon_chart_all.csv\"\n",
"PRODUCER_PATH = \"./data/producer_all.csv\"\n",
"OUTPUT_PATH = \"./data/gaon_chart_all_cleanup.xlsx\""
]
},
{
Expand Down Expand Up @@ -131,19 +131,23 @@
"import pandas as pd\n",
"import numpy as np\n",
"\n",
"sales = pd.read_csv(CHART_PATH,\n",
" usecols=['selector', 'production', 'title', 'artist', 'sales_volume'])\n",
"sales.rename(columns={'selector': 'month'}, inplace=True)\n",
"sales = sales.astype({'month': 'int32'}, errors='raise')\n",
"sales[['monthly_sales', 'annual_sales']\n",
" ] = sales['sales_volume'].str.split('/', 1, expand=True)\n",
"sales = sales.drop(columns=['sales_volume']).drop_duplicates(\n",
" ['title', 'artist', 'month'])\n",
"sales = pd.read_csv(\n",
" CHART_PATH, usecols=[\"selector\", \"production\", \"title\", \"artist\", \"sales_volume\"]\n",
")\n",
"sales.rename(columns={\"selector\": \"month\"}, inplace=True)\n",
"sales = sales.astype({\"month\": \"int32\"}, errors=\"raise\")\n",
"sales[[\"monthly_sales\", \"annual_sales\"]] = sales[\"sales_volume\"].str.split(\n",
" \"/\", 1, expand=True\n",
")\n",
"sales = sales.drop(columns=[\"sales_volume\"]).drop_duplicates(\n",
" [\"title\", \"artist\", \"month\"]\n",
")\n",
"sales = sales.reindex(\n",
" columns=['month', 'title', 'artist', 'production', 'monthly_sales', 'annual_sales'])\n",
"sales = sales.sort_values(by=['month', 'monthly_sales'])\n",
"sales = sales.sort_values(by=['monthly_sales'])\n",
"sales.head()\n"
" columns=[\"month\", \"title\", \"artist\", \"production\", \"monthly_sales\", \"annual_sales\"]\n",
")\n",
"sales = sales.sort_values(by=[\"month\", \"monthly_sales\"])\n",
"sales = sales.sort_values(by=[\"monthly_sales\"])\n",
"sales.head()"
]
},
{
Expand Down Expand Up @@ -228,14 +232,14 @@
],
"source": [
"## Get producer data from raw gaon chart data\n",
"producer = pd.read_csv(PRODUCER_PATH, usecols=['link', 'artist', 'producer'])\n",
"producer = pd.read_csv(PRODUCER_PATH, usecols=[\"link\", \"artist\", \"producer\"])\n",
"producer.rename(columns={\"link\": \"month\"}, inplace=True)\n",
"producer = producer.astype({'month': 'int32'}, errors='raise')\n",
"producer['artist'] = producer['artist'].str.split('|', 1).str[0]\n",
"producer = producer.drop_duplicates(subset=['artist', 'producer'], keep='first')\n",
"producer = producer.astype({\"month\": \"int32\"}, errors=\"raise\")\n",
"producer[\"artist\"] = producer[\"artist\"].str.split(\"|\", 1).str[0]\n",
"producer = producer.drop_duplicates(subset=[\"artist\", \"producer\"], keep=\"first\")\n",
"## Caution: Some artists has multiple agencies that has changed\n",
"producer = producer.reindex(columns=['artist', 'month', 'producer'])\n",
"producer = producer.sort_values(by=['artist', 'month'])\n",
"producer = producer.reindex(columns=[\"artist\", \"month\", \"producer\"])\n",
"producer = producer.sort_values(by=[\"artist\", \"month\"])\n",
"producer.head()"
]
},
Expand Down Expand Up @@ -440,18 +444,32 @@
],
"source": [
"## Search producer from producer dataframe and insert into new_sales\n",
"new_sales = pd.merge(left=sales, right=producer, how='left', on='artist') # merge two dataframe\n",
"new_sales = pd.merge(\n",
" left=sales, right=producer, how=\"left\", on=\"artist\"\n",
") # merge two dataframe\n",
"## clean up the data\n",
"new_sales['month_y'] = new_sales['month_y'].fillna(1800)\n",
"new_sales['producer'] = new_sales['producer'].fillna('미상')\n",
"new_sales = new_sales.astype({'month_y': 'int32'}, errors='raise')\n",
"new_sales[\"month_y\"] = new_sales[\"month_y\"].fillna(1800)\n",
"new_sales[\"producer\"] = new_sales[\"producer\"].fillna(\"미상\")\n",
"new_sales = new_sales.astype({\"month_y\": \"int32\"}, errors=\"raise\")\n",
"## find the producer artist belonged to before the release of the album\n",
"new_sales[new_sales['month_x'] >= new_sales['month_y']] \n",
"new_sales = new_sales.sort_values('month_y', ascending=True).drop_duplicates(['title', 'artist', 'month_x'])\n",
"new_sales.rename(columns={'month_x': 'month'}, inplace=True)\n",
"new_sales = new_sales.drop(columns=['month_y'])\n",
"new_sales = new_sales.reindex(columns=['month', 'title', 'artist', 'producer', 'production', 'monthly_sales', 'annual_sales'])\n",
"new_sales = new_sales.sort_values(by=['month', 'monthly_sales'])\n",
"new_sales[new_sales[\"month_x\"] >= new_sales[\"month_y\"]]\n",
"new_sales = new_sales.sort_values(\"month_y\", ascending=True).drop_duplicates(\n",
" [\"title\", \"artist\", \"month_x\"]\n",
")\n",
"new_sales.rename(columns={\"month_x\": \"month\"}, inplace=True)\n",
"new_sales = new_sales.drop(columns=[\"month_y\"])\n",
"new_sales = new_sales.reindex(\n",
" columns=[\n",
" \"month\",\n",
" \"title\",\n",
" \"artist\",\n",
" \"producer\",\n",
" \"production\",\n",
" \"monthly_sales\",\n",
" \"annual_sales\",\n",
" ]\n",
")\n",
"new_sales = new_sales.sort_values(by=[\"month\", \"monthly_sales\"])\n",
"new_sales"
]
},
Expand Down Expand Up @@ -922,7 +940,13 @@
}
],
"source": [
"sales_table = pd.pivot_table(new_sales, values=\"monthly_sales\", index=['producer', 'artist', 'title'], columns=\"month\", aggfunc=np.sum).fillna(0)\n",
"sales_table = pd.pivot_table(\n",
" new_sales,\n",
" values=\"monthly_sales\",\n",
" index=[\"producer\", \"artist\", \"title\"],\n",
" columns=\"month\",\n",
" aggfunc=np.sum,\n",
").fillna(0)\n",
"sales_table"
]
},
Expand All @@ -933,11 +957,11 @@
"outputs": [],
"source": [
"# Create a Pandas Excel writer using XlsxWriter as the engine.\n",
"writer = pd.ExcelWriter(OUTPUT_PATH, engine='xlsxwriter')\n",
"sales_table.to_excel(writer, sheet_name='cleanup')\n",
"new_sales.to_excel(writer, sheet_name='sales_with_producer')\n",
"sales.to_excel(writer, sheet_name='raw_sales')\n",
"producer.to_excel(writer, sheet_name='raw_producer')\n",
"writer = pd.ExcelWriter(OUTPUT_PATH, engine=\"xlsxwriter\")\n",
"sales_table.to_excel(writer, sheet_name=\"cleanup\")\n",
"new_sales.to_excel(writer, sheet_name=\"sales_with_producer\")\n",
"sales.to_excel(writer, sheet_name=\"raw_sales\")\n",
"producer.to_excel(writer, sheet_name=\"raw_producer\")\n",
"writer.save()"
]
}
Expand Down
94 changes: 47 additions & 47 deletions dev-jobs-cron/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,48 +1,48 @@
{
"cSpell.words": [
"notionhq",
"Igfz",
"EAAYASAA",
"mkto",
"gpfdrxfd",
"Nfwo",
"Blbnh",
"EFXs",
"VLSTGD",
"gpfdrxfd",
"VEZSR",
"VLNS",
"Vlhk",
"MUUZ",
"GFOUDZFSHN",
"ghvtp",
"KHTML",
"KHTML",
"Igfz",
"EAAYASAA",
"mkto",
"gpfdrxfd",
"Nfwo",
"Blbnh",
"EFXs",
"VLSTGD",
"gpfdrxfd",
"VEZSR",
"VLNS",
"Vlhk",
"MUUZ",
"GFOUDZFSHN",
"ghvtp",
"GOODTV",
"GOODTV",
"notionhq",
"notionhq",
"KHTML",
"apng",
"ECONN",
"notionhq",
"wdlist",
"KHTML",
"typecheck"
],
}
"cSpell.words": [
"notionhq",
"Igfz",
"EAAYASAA",
"mkto",
"gpfdrxfd",
"Nfwo",
"Blbnh",
"EFXs",
"VLSTGD",
"gpfdrxfd",
"VEZSR",
"VLNS",
"Vlhk",
"MUUZ",
"GFOUDZFSHN",
"ghvtp",
"KHTML",
"KHTML",
"Igfz",
"EAAYASAA",
"mkto",
"gpfdrxfd",
"Nfwo",
"Blbnh",
"EFXs",
"VLSTGD",
"gpfdrxfd",
"VEZSR",
"VLNS",
"Vlhk",
"MUUZ",
"GFOUDZFSHN",
"ghvtp",
"GOODTV",
"GOODTV",
"notionhq",
"notionhq",
"KHTML",
"apng",
"ECONN",
"notionhq",
"wdlist",
"KHTML",
"typecheck"
]
}
10 changes: 5 additions & 5 deletions dev-jobs-cron/babel.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
presets: [
['@babel/preset-env', { targets: { node: 'current' } }],
'@babel/preset-typescript',
],
};
presets: [
["@babel/preset-env", { targets: { node: "current" } }],
"@babel/preset-typescript",
],
};
20 changes: 10 additions & 10 deletions dev-jobs-cron/jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import type { Config } from '@jest/types';
import type { Config } from "@jest/types";

// Sync object
const config: Config.InitialOptions = {
verbose: true,
preset: 'ts-jest',
testEnvironment: 'node',
transform: {
'\\.[jt]sx?$': 'ts-jest',
},
transformIgnorePatterns: ['ts-jest'],
}
verbose: true,
preset: "ts-jest",
testEnvironment: "node",
transform: {
"\\.[jt]sx?$": "ts-jest",
},
transformIgnorePatterns: ["ts-jest"],
};

export default config
export default config;
64 changes: 32 additions & 32 deletions dev-jobs-cron/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
{
"compilerOptions": {
"preserveConstEnums": true,
"strictNullChecks": true,
"sourceMap": true,
"allowJs": true,
"target": "ES2015",
"outDir": ".build",
"module": "CommonJS",
"moduleResolution": "node",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"skipLibCheck": true,
"resolveJsonModule": true,
"lib": ["es2015"],
"rootDir": "./",
// Emit sourcemaps
"declaration": true,
"declarationMap": true,
"inlineSources": true,
// Emit type definitions
"strict": true,
// Linter style rules
"noUnusedLocals": true, // Disabled because we use eslint for this.
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedIndexedAccess": false,
"noPropertyAccessFromIndexSignature": true,
"noImplicitAny": true
},
"exclude": ["node_modules"],
"types": ["node", "aws-sdk", "notionhq", "axios"],
"include": ["*.ts", "test/**.ts", "types/**.ts"]
"compilerOptions": {
"preserveConstEnums": true,
"strictNullChecks": true,
"sourceMap": true,
"allowJs": true,
"target": "ES2015",
"outDir": ".build",
"module": "CommonJS",
"moduleResolution": "node",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"skipLibCheck": true,
"resolveJsonModule": true,
"lib": ["es2015"],
"rootDir": "./",
// Emit sourcemaps
"declaration": true,
"declarationMap": true,
"inlineSources": true,
// Emit type definitions
"strict": true,
// Linter style rules
"noUnusedLocals": true, // Disabled because we use eslint for this.
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedIndexedAccess": false,
"noPropertyAccessFromIndexSignature": true,
"noImplicitAny": true
},
"exclude": ["node_modules"],
"types": ["node", "aws-sdk", "notionhq", "axios"],
"include": ["*.ts", "test/**.ts", "types/**.ts"]
}
2 changes: 1 addition & 1 deletion social-count/event.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
"detail": {
"ip": "121.131.178.122"
}
}
}
Loading

0 comments on commit c33f84e

Please sign in to comment.