Python Forum
Pandas converting date to epoch
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pandas converting date to epoch
#1
Hello all,

ok, this has stumped me for at least the last 6 hours and i am ready to pull what little hair i have left out!

I have a dataframe that i filled from a .xls
in it is a couple dates

i am trying to take those and add them to my sqlite database but i have hit error after error..

my brain has fried so i am not going to attempt to post the whole progression into how i got here but this is where i am at: (i believe its error number 12 or so)..
#this is where is separate the dataframe item. i am trying to reduce it back to epoch
fd = fd_db.iloc[dfb]['8']
fd = fd.strftime('%Y-%m-%d')

# then I am trying to add it into my sqlite statement:

            sql_in = """INSERT INTO returns(
            id = """ + row['3'] + """, 
            efin = """ + row['2'] + """, 
            fname = """ + row['5'] + """, 
            lname = """ + row['4'] + """, 
            tin = """ + str(self.key) + """, 
            fedlvl = """ + str(fl) + """, 
            feddate = """ + str(fd) + """, 
            statelvl = """ + str(row['6']) + """, 
            statedate = '', 
            starttime = """ + str(self.key) + """, 
            adminbypass = '', 
            comment = '', 
            end_date = ''
            ) ON CONFLICT(id) DO UPDATE SET
            tin=""" + str(self.key) + """, 
            fedlvl=""" + fl + """, 
            feddate=""" + str(fd) + """,  
            statedate=''
            ;"""
the error:
Error:
fd = fd.strftime('%Y-%m-%d') AttributeError: 'float' object has no attribute 'strftime'
i am at my wits end.. any suggestions?

ps: the dates, some have dates (19-11-16) but a few are empty.. which i think is whats causing problems..
Reply


Messages In This Thread
Pandas converting date to epoch - by randor - Jul-15-2019, 10:40 PM
RE: Pandas converting date to epoch - by metulburr - Jul-15-2019, 11:22 PM
RE: Pandas converting date to epoch - by scidam - Jul-16-2019, 02:41 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Pandas read csv file in 'date/time' chunks MorganSamage 4 1,649 Feb-13-2023, 11:24 AM
Last Post: MorganSamage
  Does a pandas have a date without a time? AlekseyPython 6 4,875 Feb-10-2021, 09:24 AM
Last Post: Naheed
  (Solved) Converting Dollar Amount Str to Int with Pandas calvinsomething 3 3,750 Nov-19-2020, 01:31 PM
Last Post: calvinsomething
  replace nan values by mean group by date.year, date.month wissam1974 5 8,331 Feb-19-2020, 06:25 PM
Last Post: AnkitGupta
  Obtaining Correct Date In Pandas DataFrame eddywinch82 14 5,851 Feb-17-2020, 11:45 AM
Last Post: eddywinch82
  Trying to Pass date to pandas search from input prompt curranjohn46 1 2,073 Oct-10-2019, 10:01 AM
Last Post: curranjohn46
  Need help passing date to pandas query curranjohn46 1 5,423 Oct-10-2019, 09:59 AM
Last Post: curranjohn46
  Pandas and Date: problem with operator.How to resolve frame 6 4,274 May-13-2019, 05:50 PM
Last Post: frame
  Working with date indexes (pandas) dervast 0 1,937 Apr-05-2019, 01:29 PM
Last Post: dervast
  Converting string the pandas dataframe chrismc 0 2,336 Jan-24-2019, 11:07 AM
Last Post: chrismc

Forum Jump:

User Panel Messages

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