You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()
pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()
pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()
pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()
KeyError: 'content'
The above exception was the direct cause of the following exception:
KeyError Traceback (most recent call last)
/opt/anaconda3/lib/python3.8/site-packages/tableau_api_lib/utils/common.py in flatten_dict_column(df, keys, col_name, add_col_prefix)
20 if add_col_prefix is True:
---> 21 df[col_name + "_" + key] = df[col_name].apply(lambda col: col[key])
22 elif add_col_prefix is False:
/opt/anaconda3/lib/python3.8/site-packages/pandas/core/frame.py in getitem(self, key)
3023 return self._getitem_multilevel(key)
-> 3024 indexer = self.columns.get_loc(key)
3025 if is_integer(indexer):
/opt/anaconda3/lib/python3.8/site-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
3081 except KeyError as err:
-> 3082 raise KeyError(key) from err
3083
KeyError: 'content'
During handling of the above exception, another exception occurred:
KeyError Traceback (most recent call last)
in
3 for i in range(len(all_sites)):
4 #conn.switch_site(all_sites.loc[i,'contentUrl']) # Here we are switching to each site
----> 5 all_user=querying.get_subscriptions_dataframe(conn)
6
/opt/anaconda3/lib/python3.8/site-packages/tableau_api_lib/utils/common.py in flatten_dict_column(df, keys, col_name, add_col_prefix)
28 except KeyError:
29 # TODO(elliott): change the col_name reference below be the key name when the key is what's missing
---> 30 raise KeyError(f"No column named '{col_name}' was found in the DataFrame provided.")
31
32
KeyError: "No column named 'content' was found in the DataFrame provided."
The text was updated successfully, but these errors were encountered:
Hey @agrasurbhi try this: run pip install -U tableau-api-lib to get the most recent version of the library. Re-run your code, and now if the resulting dataframe does not have the content column then you will receive an empty dataframe rather than getting this error.
I also recommend running this to determine if there is some other issue at play:
If you are seeing some sort of error when querying your subscriptions then please post it to this thread and I'll try to help.
This query_subscriptions method hits the actual REST API endpoint "Query Subscriptions" and this is in turn used by the querying.get_subscriptions_dataframe function. If you have any trouble querying the subscriptions via the actual endpoint, then this explains why the querying function is not working for you.
KeyError Traceback (most recent call last)
/opt/anaconda3/lib/python3.8/site-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
3079 try:
-> 3080 return self._engine.get_loc(casted_key)
3081 except KeyError as err:
pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()
pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()
pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()
pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()
KeyError: 'content'
The above exception was the direct cause of the following exception:
KeyError Traceback (most recent call last)
/opt/anaconda3/lib/python3.8/site-packages/tableau_api_lib/utils/common.py in flatten_dict_column(df, keys, col_name, add_col_prefix)
20 if add_col_prefix is True:
---> 21 df[col_name + "_" + key] = df[col_name].apply(lambda col: col[key])
22 elif add_col_prefix is False:
/opt/anaconda3/lib/python3.8/site-packages/pandas/core/frame.py in getitem(self, key)
3023 return self._getitem_multilevel(key)
-> 3024 indexer = self.columns.get_loc(key)
3025 if is_integer(indexer):
/opt/anaconda3/lib/python3.8/site-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
3081 except KeyError as err:
-> 3082 raise KeyError(key) from err
3083
KeyError: 'content'
During handling of the above exception, another exception occurred:
KeyError Traceback (most recent call last)
in
3 for i in range(len(all_sites)):
4 #conn.switch_site(all_sites.loc[i,'contentUrl']) # Here we are switching to each site
----> 5 all_user=querying.get_subscriptions_dataframe(conn)
6
/opt/anaconda3/lib/python3.8/site-packages/tableau_api_lib/utils/querying/subscriptions.py in get_subscriptions_dataframe(conn)
17 def get_subscriptions_dataframe(conn):
18 subscriptions_df = pd.DataFrame(get_all_subscription_fields(conn))
---> 19 subscriptions_df = flatten_dict_column(subscriptions_df, keys=['id', 'type'], col_name='content')
20 subscriptions_df = flatten_dict_column(subscriptions_df, keys=['id', 'name'], col_name='schedule')
21 subscriptions_df = flatten_dict_column(subscriptions_df, keys=['id', 'name'], col_name='user')
/opt/anaconda3/lib/python3.8/site-packages/tableau_api_lib/utils/common.py in flatten_dict_column(df, keys, col_name, add_col_prefix)
28 except KeyError:
29 # TODO(elliott): change the
col_name
reference below be the key name when the key is what's missing---> 30 raise KeyError(f"No column named '{col_name}' was found in the DataFrame provided.")
31
32
KeyError: "No column named 'content' was found in the DataFrame provided."
The text was updated successfully, but these errors were encountered: