Bottom Page

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..
Quote
#2
whatever this is getting
Quote:fd_db.iloc[dfb]['8']
its returning a float, not a string as expected
Quote
#3
You can try to use .to_sql method of df-instance.
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Trying to Pass date to pandas search from input prompt curranjohn46 1 125 Oct-10-2019, 10:01 AM
Last Post: curranjohn46
  Need help passing date to pandas query curranjohn46 1 142 Oct-10-2019, 09:59 AM
Last Post: curranjohn46
  replace nan values by mean group by date.year, date.month wissam1974 4 487 Jul-06-2019, 02:00 AM
Last Post: wissam1974
  Pandas and Date: problem with operator.How to resolve frame 6 1,179 May-13-2019, 05:50 PM
Last Post: frame
  Working with date indexes (pandas) dervast 0 367 Apr-05-2019, 01:29 PM
Last Post: dervast
  Converting string the pandas dataframe chrismc 0 403 Jan-24-2019, 11:07 AM
Last Post: chrismc
  Error: Slicing a single date from Pandas cheerful 0 623 Jul-22-2018, 08:09 PM
Last Post: cheerful
  Finding date count from a list of date range in pandas trillerducas72 0 664 May-24-2018, 02:30 AM
Last Post: trillerducas72
  pandas convert date/time to week okl 3 2,530 Mar-03-2018, 10:15 PM
Last Post: marsokod
  is a pandas dataframe timeseries time index in a specified range (but ignoring date)? m_lotinga 4 13,402 Dec-12-2016, 10:51 PM
Last Post: m_lotinga

Forum Jump:


Users browsing this thread: 1 Guest(s)