Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
mikes zhang
001
提交
a18d1be5
0
001
项目概览
mikes zhang
/
001
通知
6
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
0
001
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
a18d1be5
编写于
6月 20, 2020
作者:
D
Doug Farrell
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Modified code based on CircleCI failures
上级
81ed09a9
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
16 addition
and
14 deletion
+16
-14
python-sqlite-sqlalchemy/project/build_data/build_author_book_publisher_sqlite.py
.../project/build_data/build_author_book_publisher_sqlite.py
+3
-1
python-sqlite-sqlalchemy/project/examples/example_1/main.py
python-sqlite-sqlalchemy/project/examples/example_1/main.py
+13
-12
python-sqlite-sqlalchemy/project/examples/example_2/main.py
python-sqlite-sqlalchemy/project/examples/example_2/main.py
+0
-1
未找到文件。
python-sqlite-sqlalchemy/project/build_data/build_author_book_publisher_sqlite.py
浏览文件 @
a18d1be5
...
...
@@ -34,7 +34,9 @@ def populate_database(session, author_book_publisher_data):
.
one_or_none
()
)
if
author
is
None
:
author
=
Author
(
first_name
=
row
[
"first_name"
],
last_name
=
row
[
"last_name"
])
author
=
Author
(
first_name
=
row
[
"first_name"
],
last_name
=
row
[
"last_name"
]
)
session
.
add
(
author
)
book
=
(
...
...
python-sqlite-sqlalchemy/project/examples/example_1/main.py
浏览文件 @
a18d1be5
"""
This is the example 1 program file
This example program was kindly created by Geir Arne Hjelle, another RealPython author,
as part of the editorial process to improve this article and the information it presents.
You can learn more about Geir from this URL: https://realpython.com/team/gahjelle/
This example program was kindly created by Geir Arne Hjelle,
another RealPython author, as part of the editorial process
to improve this article and the information it presents.
You can learn more about Geir from this URL:
https://realpython.com/team/gahjelle/
"""
from
importlib
import
resources
from
typing
import
List
import
pandas
as
pd
from
treelib
import
Tree
...
...
@@ -25,15 +26,14 @@ def get_books_by_publisher(
a Pandas series
Args:
data (pd.DataFrame): The Pandas dataframe to get the data from
ascending (bool, optional): The sorting direction for the returned data. Defaults to True.
data (pd.DataFrame): The Pandas dataframe to get the
data from ascending (bool, optional): The sorting
direction for the returned data. Defaults to True.
Returns:
pd.Series: The sorted data as a Pandas series
"""
return
data
.
groupby
(
"publisher"
)
\
.
size
()
\
.
sort_values
(
ascending
=
ascending
)
return
data
.
groupby
(
"publisher"
).
size
().
sort_values
(
ascending
=
ascending
)
def
get_authors_by_publisher
(
...
...
@@ -43,8 +43,9 @@ def get_authors_by_publisher(
a Panda series
Args:
data (pd.DataFrame): The Pandas dataframe to get the data from
ascending (bool, optional): The sorting direction for the returned data. Defaults to True.
data (pd.DataFrame): The Pandas dataframe to get the data
from ascending (bool, optional): The sorting direction for
the returned data. Defaults to True.
Returns:
pd.Series: The sorted data as a Pandas series
...
...
@@ -92,7 +93,7 @@ def add_new_book(
def
output_author_hierarchy
(
data
:
pd
.
DataFrame
):
"""This function outputs the data as a hierarchy with
"""This function outputs the data as a hierarchy with
the authors as the root node
"""
authors
=
data
.
assign
(
...
...
python-sqlite-sqlalchemy/project/examples/example_2/main.py
浏览文件 @
a18d1be5
...
...
@@ -5,7 +5,6 @@ This program gathers information from the temp_data.csv file about temperature
from
typing
import
List
from
uuid
import
uuid4
from
flask_sqlalchemy
import
SQLAlchemy
from
pkg_resources
import
resource_filename
from
sqlalchemy
import
and_
,
create_engine
from
sqlalchemy.orm
import
sessionmaker
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录