该 ai.summarize 函数使用生成式 AI 生成输入文本摘要,并包含一行代码。 该函数可以从数据帧的一列汇总值,也可以汇总所有列中的值。
注释
概述
ai.summarize 函数扩展了 pandas Series 类。 若要单独汇总该列中的每一行值,请对 pandas DataFrame 文本列调用该函数。 还可以在整个 DataFrame 上调用 ai.summarize 函数,以汇总所有列的值。
该函数返回一个 pandas Series,其中包含摘要,这些摘要可以存储在新的 DataFrame 列中。
Syntax
参数
None
退货
该函数返回一个 pandas Series ,其中包含每个输入文本行的摘要。 如果输入的文本是 null,则结果为 null。
Example
# This code uses AI. Always review output for mistakes.
# Read terms: https://azure.microsoft.com/support/legal/preview-supplemental-terms/.
df= pd.DataFrame([
("Microsoft Teams", "2017",
"""
The ultimate messaging app for your organization—a workspace for real-time
collaboration and communication, meetings, file and app sharing, and even the
occasional emoji! All in one place, all in the open, all accessible to everyone.
"""),
("Microsoft Fabric", "2023",
"""
An enterprise-ready, end-to-end analytics platform that unifies data movement,
data processing, ingestion, transformation, and report building into a seamless,
user-friendly SaaS experience. Transform raw data into actionable insights.
""")
], columns=["product", "release_year", "description"])
df["summaries"] = df["description"].ai.summarize()
display(df)
此示例代码单元提供以下输出:
相关内容
使用 ai.analyze_sentiment检测情绪。
使用 ai.classify 对文本进行分类。
使用 ai_extract提取实体。
使用 ai.fix_grammar修复语法。
使用 ai.generate_response回答自定义用户提示。
使用 ai.translate 翻译文本。
详细了解 完整的 AI 函数集。
自定义 AI 函数的配置。
我们错过了所需的功能吗? 在面料创意论坛上提出建议。