-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat (component-service): new section
- Loading branch information
Showing
14 changed files
with
7,069,896 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,4 +37,8 @@ build/ | |
*.class | ||
|
||
## Node ## | ||
node_modules | ||
node_modules | ||
|
||
### Python ### | ||
*.pyc | ||
__pycache__/ |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"{'fcid_code': '600349000', 'correlation': -0.42727039243602566, 'p_value': 1.3055703823764138e-50}\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"import pandas as pd\n", | ||
"from scipy import stats\n", | ||
"\n", | ||
"# Load the CSV file\n", | ||
"df = pd.read_csv(\"intake-person-demo(age).csv\", dtype={'fcid_code': str})\n", | ||
"\n", | ||
"def get_correlation(fcid_code):\n", | ||
" # Filter the dataframe for the given fcid_code\n", | ||
" filtered_df = df[df['fcid_code'] == fcid_code]\n", | ||
" \n", | ||
" # Check if there's data for the given fcid_code\n", | ||
" if filtered_df.empty:\n", | ||
" return {\"error\": \"No data found for the given fcid_code\"}\n", | ||
" \n", | ||
" # Calculate the correlation between age and intake_bw\n", | ||
" correlation, p_value = stats.pearsonr(filtered_df['age'], filtered_df['intake_bw'])\n", | ||
" \n", | ||
" return {\n", | ||
" \"fcid_code\": fcid_code,\n", | ||
" \"correlation\": correlation,\n", | ||
" \"p_value\": p_value\n", | ||
" }\n", | ||
"\n", | ||
"# Example usage\n", | ||
"result = get_correlation(\"600349000\")\n", | ||
"print(result)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"To use this function, make sure you have the required libraries installed and the CSV file in the same directory as your notebook. You can install the libraries using:\n", | ||
"\n", | ||
"```\n", | ||
"!pip install pandas scipy\n", | ||
"```\n", | ||
"\n", | ||
"Then, you can call the function with different fcid_codes to get the correlation:" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Example usage with multiple fcid_codes\n", | ||
"fcid_codes = [\"code1\", \"code2\", \"code3\"]\n", | ||
"\n", | ||
"for code in fcid_codes:\n", | ||
" result = get_correlation(code)\n", | ||
" print(f\"Result for {code}:\")\n", | ||
" print(result)\n", | ||
" print()" | ||
] | ||
} | ||
], | ||
"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.10.12" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 4 | ||
} |
Oops, something went wrong.