For some reason Im getting a column added to a totally different dataframe. Im not sure why

print("data4.4.1",data.to_string())

df['hr'] = - state_means[:,0]

print("data4.4.2",data.to_string())

data4.4.1                            Forex(AUD/USD [1])  Forex(EUR/CHF [2])  Forex(EUR/JPY [3])  Forex(EUR/USD [4])  Forex(GBP/JPY [5])  Forex(GBP/USD [6])  Forex(NZD/USD [7])  Forex(USD/CAD [8])  Forex(USD/CHF [9])  Forex(USD/JPY [10])
2020-12-23 00:00:00-05:00            0.758130            1.083355            126.4065            1.220465            140.3370            1.354975            0.709325            1.284930            0.887680             103.5740
2020-12-24 00:00:00-05:00            0.759520            1.085680            126.3100            1.218150            140.3120            1.353395            0.711400            1.284365            0.891310             103.6760
2020-12-25 00:00:00-05:00            0.759520            1.085680            126.3100            1.218150            140.3120            1.353395            0.711400            1.284365            0.891310             103.6760
2020-12-26 00:00:00-05:00            0.759520            1.085680            126.3100            1.218150            140.3120            1.353395            0.711400            1.284365            0.891310             103.6760
2020-12-27 00:00:00-05:00            0.760865            1.086765            126.4300            1.221040            140.4355            1.356300            0.712180            1.284470            0.890015             103.5415
2020-12-28 00:00:00-05:00            0.759440            1.085720            126.9415            1.223980            139.9135            1.349060            0.711940            1.282730            0.887030             103.6780
2020-12-29 00:00:00-05:00            0.765615            1.083590            126.8960            1.228505            139.8815            1.354245            0.718590            1.279050            0.882030             103.2915
2020-12-30 00:00:00-05:00            0.770025            1.083900            126.7470            1.228675            140.4455            1.361470            0.722200            1.274610            0.882165             103.1575
2020-12-31 00:00:00-05:00            0.770060            1.081870            126.1370            1.221605            141.0160            1.365710            0.718780            1.275660            0.885625             103.2560
2021-01-01 00:00:00-05:00            0.770060            1.081870            126.1370            1.221605            141.0160            1.365710            0.718780            1.275660            0.885625             103.2560
2021-01-02 00:00:00-05:00            0.771130            1.081895            126.4770            1.224995            141.2495            1.368080            0.719600            1.272390            0.883155             103.2470
2021-01-03 00:00:00-05:00            0.766965            1.079820            126.3705            1.225280            139.9660            1.357095            0.717845            1.278140            0.881285             103.1355
data4.4.2                            Forex(AUD/USD [1])  Forex(EUR/CHF [2])  Forex(EUR/JPY [3])  Forex(EUR/USD [4])  Forex(GBP/JPY [5])  Forex(GBP/USD [6])  Forex(NZD/USD [7])  Forex(USD/CAD [8])  Forex(USD/CHF [9])  Forex(USD/JPY [10])        hr
2020-04-19 00:00:00-04:00            0.634305            1.051770            117.1310            1.086110            134.5125            1.247280            0.602265            1.407510            0.968370             107.8455 -0.244560
2020-04-20 00:00:00-04:00            0.630415            1.051605            116.5605            1.083765            133.4170            1.240495            0.599300            1.415750            0.970290             107.5515 -0.349590
2020-04-21 00:00:00-04:00            0.630495            1.052825            116.8865            1.085075            132.3590            1.228705            0.596125            1.421925            0.970270             107.7210 -0.404707
2020-04-22 00:00:00-04:00            0.630040            1.051440            116.5075            1.080935            132.8475            1.232535            0.593845            1.418120            0.972685             107.7830 -0.438411
2020-04-23 00:00:00-04:00            0.635890            1.052125            115.9745            1.077130            133.0125            1.235390            0.599480            1.406785            0.976810             107.6695 -0.461103
2020-04-24 00:00:00-04:00            0.639685            1.053155            116.3330            1.082475            132.9030            1.236650            0.601730            1.409825            0.972825             107.4695 -0.477534
2020-04-25 00:00:00-04:00            0.639685            1.053155            116.3330            1.082475            132.9030            1.236650            0.601730            1.409825            0.972825             107.4695 -0.490043
2020-04-26 00:00:00-04:00            0.643420            1.054330            116.2885            1.083195            133.1520            1.240280            0.604315            1.407115            0.973355             107.3560 -0.499918
2020-04-27 00:00:00-04:00            0.644325            1.056340            116.1285            1.082435            133.2045            1.241670            0.600350            1.405580            0.975865             107.2805 -0.507938
2020-04-28 00:00:00-04:00            0.653475            1.055210            115.5480            1.084680            132.8960            1.247485            0.609850            1.394655            0.972815             106.5305 -0.514571

A strange thing is happening when I use the line for some reason Im getting the hr added to a totally different dataframe. Im not sure why.

Hi,



It seems difficult to know the reason for this happening based on the information given so far. There could be a code line in between where you are performing an operation which replaces the existing dataframe. 



 

Honestly there isnt a thing between the lines shown. Its very very odd. Its making me wonder if your planform can have strange runtime errors.

Hi Jane,

I think it would be helpful to first determine if the issue is specific to the platform or if it is a problem with the code itself.



To do this, I suggest trying the code on a local python notebook using data for any asset of your choice. This will give us an idea if the problem is with the platform or if it is a problem with the code.



Blueshift uses the same Python engine, so it's unlikely that the issue you're encountering is a result of a platform-specific problem.



I hope this helps.

@Jane, for any such questions if you want us to debug, always share 1) what you did 2) what you expected 3) what you observed instead and 4) a minimal code that can reproduce the observation. Otherwise, there is little we can do to help you. Also before you ask us to debug, assume the problem is in your code (very likely) and be sure you have given your best shot. Make sure df and data are indeed two different dataframes and are not referring to the same object. Also, on Blueshift, it is usually a bad idea to name a dataframe as "data". There is a system maintanied object "data" (along with the "context" object) that are passed on to different functions (the one you query to get prices) and can cause confusion.



@Kevin, notebook and Blueshift are similar in the sense that both are Python based, but they work differently in many aspects.

  1. Can you run Blueshift now locally?


  2. I changed the variable to "data2" and the code produces the same strange error. The data2 variable is not used in the code at all only at the very end.





    I get the data from this code at the start 



    try:

    data = data.history(

    pipeline_results.index, 'close', context.lookback, '1d')

    except IndexError:

    return

    data.dropna(inplace=True, axis='columns')

    data2=data





    Only at the end to print the contents of the variable and its still adding an extra column this is very strange but the code is very long over 1200 lines.