pandas merge使用

data_read=read_data.ReadData()

data=data_read.read_data(1638,'12 12:00:00','12 18:00:00')
datels = [datetime.strptime(x, "%Y-%m-%d %H:%M:%S") for x in data['timedata']]
data['timedata']=datels
index=pd.DatetimeIndex(start=data['timedata'].min(),end=data['timedata'].max(),freq='T')
data1=DataFrame([None]*len(index),columns=['value'])
data1['timedata']=index
merge_data=data1.merge(data,left_on='timedata',right_on='timedata',how='left')
right : DataFrame or named Series
Object to merge with.
how : {‘left’, ‘right’, ‘outer’, ‘inner’}, default ‘inner’
Type of merge to be performed.
left: use only keys from left frame, similar to a SQL left outer join; preserve key order.
right: use only keys from right frame, similar to a SQL right outer join; preserve key order.
outer: use union of keys from both frames, similar to a SQL full outer join; sort keys lexicographically.
inner: use intersection of keys from both frames, similar to a SQL inner join; preserve the order of the left keys.
on : label or list
Column or index level names to join on. These must be found in both DataFrames. If on is None and not merging on indexes then this defaults to the intersection of the columns in both DataFrames.
left_on : label or list, or array-like
Column or index level names to join on in the left DataFrame. Can also be an array or list of arrays of the length of the left DataFrame. These arrays are treated as if they are columns.
right_on : label or list, or array-like
Column or index level names to join on in the right DataFrame. Can also be an array or list of arrays of the length of the right DataFrame. These arrays are treated as if they are columns.

你可能感兴趣的:(python)