why i get empty dataframe? partdf = pd.DataFrame(columns = ['mainproduct', 'startdate'])…
- User
why i get empty dataframe? part_df = pd.DataFrame(columns = ['main_product', 'start_date']) part_df['main_product'] = main_product_id.iloc[0] part_df['start_date'] = start_date.iloc[0]
client_params = pd.concat([client_params, part_df], ignore_index = True) print(client_params) - Assistant
The code provided creates an empty dataframe called
part_dfwith two columns:main_productandstart_date.Then, it assigns values to these columns by getting the first values from the
main_product_idandstart_datevariables.After that, the
part_dfdataframe is concatenated with theclient_paramsdataframe using thepd.concat()function, with theignore_indexparameter set to True.Finally, the resulting dataframe
client_paramsis printed.If the resulting
client_paramsdataframe is empty, it may mean that either themain_product_idorstart_datevariables are empty or there are no existing values at the first index.