Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Two dataframes merged
#9
for i,r in checkout.iterrows():
    ind = -1
    f = cleaned[cleaned['atime'].isnull()]
    if f is not None:
        f = f[f['date']==r['date']]
    if f is not None:
        f = f[f['dtime']<r['atime']]
    if (f is not None) & (len(f)>0):
        ind = f.index[0]
    if ind is not None:
        cleaned.iloc[ind][['atime','arrival','cost']] = r[['atime','arrival','cost']]
        #lower three lines combined into one above
        #cleaned.iloc[ind]['atime']   = r['atime']
        #cleaned.iloc[ind]['arrival'] = r['arrival']
        #cleaned.iloc[ind]['cost']    = r['cost']
Updated the dataframe - although with iterations...
Reply


Messages In This Thread
Two dataframes merged - by Ecniv - Jun-04-2019, 06:46 PM
RE: Two dataframes merged - by chisox721 - Jun-05-2019, 06:51 PM
RE: Two dataframes merged - by Ecniv - Jun-06-2019, 06:41 PM
RE: Two dataframes merged - by chisox721 - Jun-06-2019, 07:02 PM
RE: Two dataframes merged - by Ecniv - Jun-06-2019, 08:52 PM
RE: Two dataframes merged - by chisox721 - Jun-15-2019, 08:58 PM
RE: Two dataframes merged - by Ecniv - Jun-11-2019, 07:14 PM
RE: Two dataframes merged - by Ecniv - Jun-11-2019, 08:25 PM
RE: Two dataframes merged - by Ecniv - Jun-12-2019, 08:12 PM
RE: Two dataframes merged - by Ecniv - Jun-13-2019, 06:25 PM
RE: Two dataframes merged - by Ecniv - Jun-16-2019, 09:10 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Merging two DataFrames based on indexes from two other DataFrames lucinda_rigeitti 0 1,726 Jan-16-2020, 08:36 PM
Last Post: lucinda_rigeitti
  Read exel with merged cells and write to another excel SriMekala 0 2,938 Aug-10-2019, 07:14 AM
Last Post: SriMekala
  how read and write merged cells in excel SriMekala 1 15,063 Aug-07-2019, 11:27 PM
Last Post: scidam

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020