1 Star 0 Fork 0

cendeavor / mental-health-datasets

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
excel_to_markdown.py 1.87 KB
一键复制 编辑 原始数据 按行查看 历史
## Imports
import pandas as pd
from tabulate import tabulate
from datetime import datetime
## Read Data
df = pd.read_excel("data_sources.xlsx")
## Format Cells
newline_replace = lambda x: x.replace("\n","<br/>") if not isinstance(x, float) else x
strip_space = lambda x: x.strip() if not isinstance(x, float) else x
columns_to_format = ["Paper",
"Authors",
"Platform",
"Target Outcomes",
"Labeling Methodology",
"Size",
"Availability",
"Additional Comments",
"Dataset Link (if any)",
"Reference Link"]
for col in columns_to_format:
df[col] = df[col].map(newline_replace)
df[col] = df[col].map(strip_space)
## Link in Title
title_formatter = lambda row: "[{}]({})".format(row["Paper"], row["Reference Link"])
df["Paper"] = df.apply(title_formatter, axis = 1)
## Subset Columns
col_subset = ["Paper",
"Authors",
"Platform",
"Year",
"Target Outcomes"]
df = df[col_subset].copy()
## Sort by Date
df = df.sort_values("Year", ascending=False)
df = df.reset_index(drop=True)
## Generate Markdown Table
md_table = tabulate(df, tablefmt="pipe", headers="keys", showindex="never")
## Output
md_output = """
# Mental Health Datasets
The information below is an evolving list of data sets (primarily from electronic/social media) that have been used to model mental-health phenomena. The raw data (with additional columns) can be found in `data_sources.xlsx`. If you are an author of any of these papers and feel that anything is misrepresented, please do not hesitate to reach out to me at kharrigian@jhu.edu.
**Last Update**: {}
{}
""".format(datetime.now().isoformat(), md_table)
## Write Out
with open("README.md", "w") as the_file:
the_file.write(md_output)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/cendeavor/mental-health-datasets.git
git@gitee.com:cendeavor/mental-health-datasets.git
cendeavor
mental-health-datasets
mental-health-datasets
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891