如何将笨拙的表数据写入PANDAS数据框架?

发布于 2025-01-18 05:54:58 字数 607 浏览 5 评论 0原文

我正在尝试将GCP BigTable - 表读取到pandas数据帧,目前,我用来从BigTable获取行的函数是read_rows()< /code>,返回PartialRowData

代码:

from google.cloud import bigtable

client = bigtable.Client(admin=True)
instance = client.instance(bigTable_parms['instance_id'])
table = instance.table('s2')

row_data = table.read_rows()  # table.yield_rows()
for i in row_data:
    print(type(i))

输出:

<类“google.cloud.bigtable.row_data.PartialRowData”>

查询:

我们如何从 PartialRowData 对象读取值?

I am trying to read a GCP BigTable - table to a pandas dataframe, and currently, the function I am using to fetch rows from BigTable is read_rows(), which returns PartialRowData.

Code:

from google.cloud import bigtable

client = bigtable.Client(admin=True)
instance = client.instance(bigTable_parms['instance_id'])
table = instance.table('s2')

row_data = table.read_rows()  # table.yield_rows()
for i in row_data:
    print(type(i))

Output:

<class 'google.cloud.bigtable.row_data.PartialRowData'>

Query:

How do we read the values from PartialRowData obj?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

飘然心甜 2025-01-25 05:54:58

本文档中有一个有关如何调用 read_rows 的示例:
https://googleapis.dev/ python/bigtable/latest/table.html#google.cloud.bigtable.table.Table.read_rows

for row in table.read_rows():
    # replace with your own COLUMN_FAMILY_ID and COLUMN_NAME
    cell = row.cells[COLUMN_FAMILY_ID][COLUMN_NAME][0] 
    print(cell.value.decode("utf-8"))

There's an example on how to call read_rows in this documentation:
https://googleapis.dev/python/bigtable/latest/table.html#google.cloud.bigtable.table.Table.read_rows

for row in table.read_rows():
    # replace with your own COLUMN_FAMILY_ID and COLUMN_NAME
    cell = row.cells[COLUMN_FAMILY_ID][COLUMN_NAME][0] 
    print(cell.value.decode("utf-8"))
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文