Open OLR-Nadia opened 11 months ago
I got an error while accessing gslides packages for automate slides report using gslides library AttributeError: module 'pandas._libs' has no attribute 'tslibs'
This is the full error from my local machine
`--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) d:\0. DS\Research\Python Automated Report\python_automated_report.py in line 9 28 start_time = time.time() 30 get_report = utils.utils(presentation_id='xxx') ----> 31 get_report.generate_report_data('nuteaid', '2023-10-01', '2023-10-31', 'Instagram') 33 end_time = time.time() 35 elapsed_time_seconds = end_time - start_time
File d:\0. DS\Research\Python Automated Report\utils.py:6141, in utils.generate_report_data(self, username, start_date, end_date, channel) 6138 spreadsheet_id = self.sheet_id 6139 presentation_id = self.new_deck_id -> 6141 frame_ch = Frame.create(df = df_channel, 6142 spreadsheet_id = spreadsheet_id, 6143 sheet_id = sheet.sheet_names['Channel Data'], 6144 sheet_name = 'Channel Data', 6145 overwrite_data = True 6146 ) 6148 frame_co = Frame.create(df = df_content, 6149 spreadsheet_id = spreadsheet_id, 6150 sheet_id = sheet.sheet_names['Content Data'], 6151 sheet_name = 'Content Data', 6152 overwrite_data = True 6153 ) 6155 frame_pillar_avg_eng = Frame.create(df = df_pillar_avg_eng, 6156 spreadsheet_id = spreadsheet_id, 6157 sheet_id = sheet.sheet_names['Avg. Pillar Engagement'], 6158 sheet_name = 'Avg. Pillar Engagement', 6159 overwrite_data = True 6160 )
File ~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\gslides\frame.py:368, in Frame.create(cls, df, spreadsheet_id, sheet_id, sheet_name, overwrite_data, anchor_cell) 339 @classmethod 340 def create( 341 cls: Type[TFrame], (...) 347 anchor_cell: str = "A1", 348 ) -> TFrame: 349 """Creates the table of data in Google sheets 350 351 :param df: The dataframe (...) 366 367 """ --> 368 frame = CreateFrame( 369 df, 370 spreadsheet_id, 371 sheet_name, 372 overwrite_data=overwrite_data, 373 anchor_cell=anchor_cell, 374 ) 375 initialized = frame.execute() 376 return cls( 377 df, 378 spreadsheet_id, (...) 385 initialized, 386 )
File ~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\gslides\frame.py:137, in CreateFrame.init(self, df, spreadsheet_id, sheet_name, overwrite_data, anchor_cell) 135 self.start_row_index, self.start_column_index = cell_to_num(self.anchor_cell) 136 self.end_row_index, self.end_column_index = self._calc_end_index() --> 137 self._clean_df()
File ~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\gslides\frame.py:157, in CreateFrame._clean_df(self) 150 def _clean_df(self) -> None: 151 """Cleans the dataframe to convert datatypes into acceptable values for 152 the Google Sheets API 153 154 :return: Cleaned :class:pandas.DataFrame 155 :type df: :class:pandas.DataFrame 156 """ --> 157 self.df = self.df.applymap(clean_dtypes) 158 self.df = clean_nan(self.df)
pandas.DataFrame
File ~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\pandas\core\frame.py:9653, in DataFrame.applymap(self, func, na_action, **kwargs) 9650 return lib.map_infer(x, func, ignore_na=ignore_na) 9651 return lib.map_infer(x.astype(object)._values, func, ignore_na=ignore_na) -> 9653 return self.apply(infer).finalize(self, "applymap")
File ~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\pandas\core\frame.py:9568, in DataFrame.apply(self, func, axis, raw, result_type, args, **kwargs) 9557 from pandas.core.apply import frame_apply 9559 op = frame_apply( 9560 self, 9561 func=func, (...) 9566 kwargs=kwargs, 9567 ) -> 9568 return op.apply().finalize(self, method="apply")
File ~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\pandas\core\apply.py:764, in FrameApply.apply(self) 761 elif self.raw: 762 return self.apply_raw() --> 764 return self.apply_standard()
File ~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\pandas\core\apply.py:891, in FrameApply.apply_standard(self) 890 def apply_standard(self): --> 891 results, res_index = self.apply_series_generator() 893 # wrap results 894 return self.wrap_results(results, res_index)
File ~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\pandas\core\apply.py:907, in FrameApply.apply_series_generator(self) 904 with option_context("mode.chained_assignment", None): 905 for i, v in enumerate(series_gen): 906 # ignore SettingWithCopy here in case the user mutates --> 907 results[i] = self.f(v) 908 if isinstance(results[i], ABCSeries): 909 # If we have a view on v, we need to make a copy because 910 # series_generator will swap out the underlying data 911 results[i] = results[i].copy(deep=False)
File ~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\pandas\core\frame.py:9651, in DataFrame.applymap..infer(x) 9649 if x.empty: 9650 return lib.map_infer(x, func, ignore_na=ignore_na) -> 9651 return lib.map_infer(x.astype(object)._values, func, ignore_na=ignore_na)
File pandas_libs\lib.pyx:2924, in pandas._libs.lib.map_infer()
File ~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\gslides\utils.py:285, in clean_dtypes(x) 276 def clean_dtypes(x: Any) -> Union[str, float, int, np.int64, np.float64, None]: 277 """Cleans the datatypes of an obersevation to either int, float or string or None 278 279 :param x: Observation to clean (...) 283 284 """ --> 285 if type(x) in [pd._libs.tslibs.timestamps.Timestamp, datetime.date]: 286 return str(x) 287 elif type(x) in [Decimal]:
AttributeError: module 'pandas._libs' has no attribute 'tslibs'`
I kindly suggest to check on your utils.py file and revise it (if possible) Thank you.
I got an error while accessing gslides packages for automate slides report using gslides library AttributeError: module 'pandas._libs' has no attribute 'tslibs'
This is the full error from my local machine
`--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) d:\0. DS\Research\Python Automated Report\python_automated_report.py in line 9 28 start_time = time.time() 30 get_report = utils.utils(presentation_id='xxx') ----> 31 get_report.generate_report_data('nuteaid', '2023-10-01', '2023-10-31', 'Instagram') 33 end_time = time.time() 35 elapsed_time_seconds = end_time - start_time
File d:\0. DS\Research\Python Automated Report\utils.py:6141, in utils.generate_report_data(self, username, start_date, end_date, channel) 6138 spreadsheet_id = self.sheet_id
6139 presentation_id = self.new_deck_id
-> 6141 frame_ch = Frame.create(df = df_channel, 6142 spreadsheet_id = spreadsheet_id, 6143 sheet_id = sheet.sheet_names['Channel Data'], 6144 sheet_name = 'Channel Data', 6145 overwrite_data = True 6146 ) 6148 frame_co = Frame.create(df = df_content, 6149 spreadsheet_id = spreadsheet_id, 6150 sheet_id = sheet.sheet_names['Content Data'], 6151 sheet_name = 'Content Data', 6152 overwrite_data = True
6153 )
6155 frame_pillar_avg_eng = Frame.create(df = df_pillar_avg_eng, 6156 spreadsheet_id = spreadsheet_id, 6157 sheet_id = sheet.sheet_names['Avg. Pillar Engagement'], 6158 sheet_name = 'Avg. Pillar Engagement', 6159 overwrite_data = True
6160 )
File ~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\gslides\frame.py:368, in Frame.create(cls, df, spreadsheet_id, sheet_id, sheet_name, overwrite_data, anchor_cell) 339 @classmethod 340 def create( 341 cls: Type[TFrame], (...) 347 anchor_cell: str = "A1", 348 ) -> TFrame: 349 """Creates the table of data in Google sheets 350 351 :param df: The dataframe (...) 366 367 """ --> 368 frame = CreateFrame( 369 df, 370 spreadsheet_id, 371 sheet_name, 372 overwrite_data=overwrite_data, 373 anchor_cell=anchor_cell, 374 ) 375 initialized = frame.execute() 376 return cls( 377 df, 378 spreadsheet_id, (...) 385 initialized, 386 )
File ~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\gslides\frame.py:137, in CreateFrame.init(self, df, spreadsheet_id, sheet_name, overwrite_data, anchor_cell) 135 self.start_row_index, self.start_column_index = cell_to_num(self.anchor_cell) 136 self.end_row_index, self.end_column_index = self._calc_end_index() --> 137 self._clean_df()
File ~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\gslides\frame.py:157, in CreateFrame._clean_df(self) 150 def _clean_df(self) -> None: 151 """Cleans the dataframe to convert datatypes into acceptable values for 152 the Google Sheets API 153 154 :return: Cleaned :class:
pandas.DataFrame
155 :type df: :class:pandas.DataFrame
156 """ --> 157 self.df = self.df.applymap(clean_dtypes) 158 self.df = clean_nan(self.df)File ~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\pandas\core\frame.py:9653, in DataFrame.applymap(self, func, na_action, **kwargs) 9650 return lib.map_infer(x, func, ignore_na=ignore_na) 9651 return lib.map_infer(x.astype(object)._values, func, ignore_na=ignore_na) -> 9653 return self.apply(infer).finalize(self, "applymap")
File ~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\pandas\core\frame.py:9568, in DataFrame.apply(self, func, axis, raw, result_type, args, **kwargs) 9557 from pandas.core.apply import frame_apply 9559 op = frame_apply( 9560 self, 9561 func=func, (...) 9566 kwargs=kwargs, 9567 ) -> 9568 return op.apply().finalize(self, method="apply")
File ~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\pandas\core\apply.py:764, in FrameApply.apply(self) 761 elif self.raw: 762 return self.apply_raw() --> 764 return self.apply_standard()
File ~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\pandas\core\apply.py:891, in FrameApply.apply_standard(self) 890 def apply_standard(self): --> 891 results, res_index = self.apply_series_generator() 893 # wrap results 894 return self.wrap_results(results, res_index)
File ~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\pandas\core\apply.py:907, in FrameApply.apply_series_generator(self) 904 with option_context("mode.chained_assignment", None): 905 for i, v in enumerate(series_gen): 906 # ignore SettingWithCopy here in case the user mutates --> 907 results[i] = self.f(v) 908 if isinstance(results[i], ABCSeries): 909 # If we have a view on v, we need to make a copy because 910 # series_generator will swap out the underlying data 911 results[i] = results[i].copy(deep=False)
File ~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\pandas\core\frame.py:9651, in DataFrame.applymap..infer(x)
9649 if x.empty:
9650 return lib.map_infer(x, func, ignore_na=ignore_na)
-> 9651 return lib.map_infer(x.astype(object)._values, func, ignore_na=ignore_na)
File pandas_libs\lib.pyx:2924, in pandas._libs.lib.map_infer()
File ~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\gslides\utils.py:285, in clean_dtypes(x) 276 def clean_dtypes(x: Any) -> Union[str, float, int, np.int64, np.float64, None]: 277 """Cleans the datatypes of an obersevation to either int, float or string or None 278 279 :param x: Observation to clean (...) 283 284 """ --> 285 if type(x) in [pd._libs.tslibs.timestamps.Timestamp, datetime.date]: 286 return str(x) 287 elif type(x) in [Decimal]:
AttributeError: module 'pandas._libs' has no attribute 'tslibs'`
I kindly suggest to check on your utils.py file and revise it (if possible) Thank you.