python - Find the same date from two sets of data -


i new python. got 2 sets of data shown below.

set 1:

gmt time,open,high,low,close,volume,rsi,,change,gain,loss,avg gain,avg loss,rs 15.06.2017 00:00:00.000,0.75892,0.76313,0.7568,0.75858,107799.5406,0,,,,,,, 16.06.2017 00:00:00.000,0.75857,0.76294,0.75759,0.76202,94367.4299,0,,0.00344,0.00344,0,,, 18.06.2017 00:00:00.000,0.76202,0.76236,0.76152,0.76188,5926.0998,0,,-0.00014,0,0.00014,,, 19.06.2017 00:00:00.000,0.76189,0.76289,0.75848,0.75902,87514.849,0,,-0.00286,0,0.00286,,, ... 

set 2:

gmt time,open,high,low,close,volume 15.06.2017 00:00:00.000,0.75892,0.75933,0.75859,0.75883,4777.4702 15.06.2017 01:00:00.000,0.75885,0.76313,0.75833,0.76207,7452.5601 15.06.2017 02:00:00.000,0.76207,0.76214,0.76106,0.76143,4798.4102 15.06.2017 03:00:00.000,0.76147,0.76166,0.76015,0.76154,4961.4502 15.06.2017 04:00:00.000,0.76154,0.76162,0.76104,0.76121,2977.6399 15.06.2017 05:00:00.000,0.7612,0.76154,0.76101,0.76151,3105.4399 ... 

i want find lines in set 2 in same date set 1. tried this: print(daily['gmt time'][0].date == hourly['gmt time'][0].date), don't know why came out false. isn't there way compare date(just date, not including time) 2 sets of data?

first read data sets dataframes:

import pandas pd df_one = pd.dataframe.from_csv('data_set_one.csv', index_col=false) df_two = pd.dataframe.from_csv('data_set_two.csv', index_col=false) 

convert date column date

df_one['gmt date'] = pd.to_datetime(df_one['gmt time']).dt.date df_two['gmt date'] = pd.to_datetime(df_two['gmt time']).dt.date 

now compare both dataframes:

for i, row in df_one.iterrows():     df_one_date = row['gmt date']     print('df_one_date', df_one_date)     print(df_two[df_two['gmt date'] == df_one_date])     print('----') 

it's still unclear how want handle different dates df_one match df_two. hope gives enough idea on how handle it.


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -