How can I solve Pandas/Numpy datetime error: numpy.datetime64

169 Views Asked by At

I am new in this area. I just want to concatenation of two tables with the date.

The test is my other table. I want to concatenation the test and usd tables in the data table.

data = test                                 
for x in data.index.values:
    for x2 in usd.index.values:                                             
       if x == x2:                                                                                  
            np.where(usd.index==x2)
            val = usd.at[x2,"Price"]
            data.at[x,"Price"] = val                                                         

I get his errors

1

I try this usd["new_time"] = np.datetime64(usd["new_time"]) this code gets some other errors and
usd["new_time"] = np.datetime64(usd["new_time"]) this code run but it does not solve the problem I get the same errors

My tables looks like these

2

1

There are 1 best solutions below

0
stefanJonB On BEST ANSWER

You should use a join to solve this problem. I cannot give you the exact answer as it would depend on the content of both your dataframes but based on the given information the following should work.

data.join(usd,how='left')

depending on your dataframe you might have to change the 'how' argument of the join() method.