0

Trying to write code that will do the following: Read a column from an sqlite DB and put into a dataframe1.

Have a gui where a user inserts two dates, start and end. I then turn that into a date_range column dataframe2

name = 'Bob'
startDate = pd.to_datetime(str('10/02/2019'))
endDate = pd.to_datetime(str('10/09/2019'))
d=pd.date_range(start=startDate, end=endDate)

d = pd.DataFrame({'Date': d, 'Name':[name]*len(d)})


df1 = pd.DataFrame(dd, columns =['Date'])
#print(df1)

query = "select Date from testtablee"
df = pd.read_sql_query(query, engine)

print (df)

df2 = pd.DataFrame(df, columns = ['Date'])
print (df2)

This is the part I'm stuck on:

Compare the users datframe2 to existing dates in dataframe1 from SQLite. Count duplicate dates and store in a variable for each duplicated date. I do not wish to delete or remove duplicated dates, just count them. Everything I have googled will delete the duplicates. Not store it in a variable. I have no idea where to start on this phase.

Community
  • 1
  • 1
RobE
  • 93
  • 2
  • 11
  • 1
    Post some code snippet that you tried along with I/P and O/P – abheet22 Oct 04 '19 at 18:49
  • Agree with @abheet22 and would also recommend you specify your intent a bit more clearly. When you say duplicate dates, do you mean the same _day_ or literally the same `datetime`? I think you mean the former. You're using 64ns precision in your Date field, so very unlikely that you're going to find a lot of duplicates there. Also, this question may be a duplicate of [this one](https://stackoverflow.com/questions/51331775/count-identical-dates-in-pandas-dataframe) – mayosten Oct 04 '19 at 22:13
  • That's close but not exactly. I need to compare two dataframes without joining them. That example is just grouping one column. You are right about the time, I need to strip that out, I dont need time. – RobE Oct 04 '19 at 23:02

0 Answers0