I have the problem that the output for isin_dataframes is somehow not stored correctly if I want to use it in another cell. So instead of the whole DataFrame I only get one row back. Please apologize if it is not the prettiest code since it is my first coding project. The reason behind using concat was, to get NaN for the 'merge_all[isin]['value']' column back if no value is given for the same index. But that doesn't seem to work either. To adress this problem I tried to correct for the datetime format but this was not the problem for the missing data. def get_kaufdatum_for_isin(isin): filtered_data = get_isins[get_isins['ISIN'] == isin] if not filtered_data.empty: return filtered_data[['purchase', 'value']].values.tolist() else: return None #Create a dictionary to store DataFrames for each ISIN isin_dataframes = {} merge_all = {} for isin in unique_isins: # Get the purchase dates and values for this ISIN purchase_data = get_kaufdatum_for_isin(isin) # Create DataFrame with date and Gesamtwert columns get_kaufdatum = pd.DataFrame(purchase_data, columns=['date', 'value']) # Make sure date is in the correct format if needed get_kaufdatum['date'] = pd.to_datetime(get_kaufdatum['date']) get_kaufdatum.set_index('date', inplace=True) #store in dictionary isin_dataframes = get_kaufdatum #geting price-data: isin_price_data = combined_data[[isin]].copy() merge_all[isin] = pd.concat([isin_price_data, isin_dataframes]) merge_all[isin] = merge_all[isin].sort_index() merge_all[isin].rename(columns={isin: 'price'}, inplace=True) Continue reading...