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:
JavaScript
x
10
10
1
from google.cloud import bigtable
2
3
client = bigtable.Client(admin=True)
4
instance = client.instance(bigTable_parms['instance_id'])
5
table = instance.table('s2')
6
7
row_data = table.read_rows() # table.yield_rows()
8
for i in row_data:
9
print(type(i))
10
Output:
<class ‘google.cloud.bigtable.row_data.PartialRowData’>
Query:
How do we read the values from PartialRowData
obj?
Advertisement
Answer
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
JavaScript
1
5
1
for row in table.read_rows():
2
# replace with your own COLUMN_FAMILY_ID and COLUMN_NAME
3
cell = row.cells[COLUMN_FAMILY_ID][COLUMN_NAME][0]
4
print(cell.value.decode("utf-8"))
5