Alexa built-in slot AMAZON.DATE - amazon-web-services

When using the built-in slot AMAZON.DATE, "next week" is interpreted as 2016-W38 per the developer reference.
Utterances that map to just a specific week (such as “this week” or
“next week”), convert a date indicating the week number: 2015-W49.
I am trying to parse this in SQL. Is the first week of the year W1 or W01 when using the Alexa services? Thanks.

UPDATED: Dates are in ISO-8601 date format. First week is W01, there is no W00.
Reference: https://en.wikipedia.org/wiki/ISO_8601#Dates
Source: https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/alexa-skills-kit-interaction-model-reference
Original answer:
I can't find docs, but here is the answer...
Today is Wed 28th sept, day 272.
Alexa says this is 2016-W39. (I just checked).
2016 started on a Friday, so W39 started last Friday on day 267 which is 38 weeks after Jan 1st. (267/7=38.14).
Count back 38 weeks to start of year.
Therefore, first week of the year is called W1.

This is how I ended up parsing the AMAZON.DATE built-in slot using a SQL Server stored procedure.
CREATE PROCEDURE [dbo].[procMomaAlexaExhibitions]
#p_alexa_date VARCHAR(50) = ''
AS
BEGIN
SET NOCOUNT ON;
DECLARE #p_start_date VARCHAR(10) = ''
DECLARE #p_end_date VARCHAR(10) = ''
--SET #p_alexa_date = '2015-W20-WE'
-- Today if null
IF(#p_alexa_date = '' OR #p_alexa_date IS NULL)
BEGIN
SET #p_start_date = (SELECT CONVERT(VARCHAR(10), GETDATE(), 121))
SET #p_end_date = (SELECT CONVERT(VARCHAR(10), GETDATE(), 121))
END
-- Alexa provided a normal date
IF(ISDATE(#p_alexa_date) = 1)
BEGIN
SET #p_start_date = CONVERT(VARCHAR(10), #p_alexa_date, 121)
SET #p_end_date = CONVERT(VARCHAR(10), #p_alexa_date, 121)
END
-- Alexa provided a year-month
IF(LEN(#p_alexa_date) <= 8 AND ISNUMERIC(REPLACE(#p_alexa_date,'-','')) = 1)
BEGIN
SET #p_start_date = #p_alexa_date + '-01'
SET #p_end_date = #p_alexa_date + '-31'
END
-- weekend
IF(RIGHT(#p_alexa_date, 3) = '-WE')
BEGIN
DECLARE #p_week VARCHAR(2)
DECLARE #p_year VARCHAR(4)
DECLARE #p_start_date_wk VARCHAR(10) = ''
DECLARE #p_end_date_wk VARCHAR(10) = ''
SET #p_week = REPLACE(SUBSTRING(#p_alexa_date,7, LEN(#p_alexa_date)),'-WE','')
SET #p_year = LEFT(#p_alexa_date, 4)
SET #p_start_date_wk = CONVERT(VARCHAR(10), DATEADD(wk, DATEDIFF(wk, 6, '1/1/' + #p_year) + (#p_week-1), 6), 121)
SET #p_end_date_wk = CONVERT(VARCHAR(10), DATEADD(wk, DATEDIFF(wk, 5, '1/1/' + #p_year) + (#p_week-1), 5), 121)
SET #p_start_date = CASE WHEN datename(weekday, CAST(#p_start_date_wk AS smalldatetime)) = 'Saturday' THEN CONVERT(VARCHAR(10), CAST(#p_start_date_wk AS smalldatetime), 121)
WHEN datename(weekday, CAST(#p_start_date_wk AS smalldatetime) + 1) = 'Saturday' THEN CONVERT(VARCHAR(10), CAST(#p_start_date_wk AS smalldatetime) + 1, 121)
WHEN datename(weekday, CAST(#p_start_date_wk AS smalldatetime) + 2) = 'Saturday' THEN CONVERT(VARCHAR(10), CAST(#p_start_date_wk AS smalldatetime) + 2, 121)
WHEN datename(weekday, CAST(#p_start_date_wk AS smalldatetime) + 3) = 'Saturday' THEN CONVERT(VARCHAR(10), CAST(#p_start_date_wk AS smalldatetime) + 3, 121)
WHEN datename(weekday, CAST(#p_start_date_wk AS smalldatetime) + 4) = 'Saturday' THEN CONVERT(VARCHAR(10), CAST(#p_start_date_wk AS smalldatetime) + 4, 121)
WHEN datename(weekday, CAST(#p_start_date_wk AS smalldatetime) + 5) = 'Saturday' THEN CONVERT(VARCHAR(10), CAST(#p_start_date_wk AS smalldatetime) + 5, 121)
WHEN datename(weekday, CAST(#p_start_date_wk AS smalldatetime) + 6) = 'Saturday' THEN CONVERT(VARCHAR(10), CAST(#p_start_date_wk AS smalldatetime) + 6, 121)
END
SET #p_end_date = CASE WHEN datename(weekday, CAST(#p_end_date_wk AS smalldatetime)) = 'Sunday' THEN CONVERT(VARCHAR(10), CAST(#p_end_date_wk AS smalldatetime), 121)
WHEN datename(weekday, CAST(#p_end_date_wk AS smalldatetime) + 1) = 'Sunday' THEN CONVERT(VARCHAR(10), CAST(#p_end_date_wk AS smalldatetime) + 1, 121)
WHEN datename(weekday, CAST(#p_end_date_wk AS smalldatetime) + 2) = 'Sunday' THEN CONVERT(VARCHAR(10), CAST(#p_end_date_wk AS smalldatetime) + 2, 121)
WHEN datename(weekday, CAST(#p_end_date_wk AS smalldatetime) + 3) = 'Sunday' THEN CONVERT(VARCHAR(10), CAST(#p_end_date_wk AS smalldatetime) + 3, 121)
WHEN datename(weekday, CAST(#p_end_date_wk AS smalldatetime) + 4) = 'Sunday' THEN CONVERT(VARCHAR(10), CAST(#p_end_date_wk AS smalldatetime) + 4, 121)
WHEN datename(weekday, CAST(#p_end_date_wk AS smalldatetime) + 5) = 'Sunday' THEN CONVERT(VARCHAR(10), CAST(#p_end_date_wk AS smalldatetime) + 5, 121)
WHEN datename(weekday, CAST(#p_end_date_wk AS smalldatetime) + 6) = 'Sunday' THEN CONVERT(VARCHAR(10), CAST(#p_end_date_wk AS smalldatetime) + 6, 121)
END
END
-- not a weekend
IF((#p_alexa_date LIKE '%-W%') AND (RIGHT(#p_alexa_date, 3) <> '-WE'))
BEGIN
SET #p_week = SUBSTRING(#p_alexa_date,7, LEN(#p_alexa_date))
SET #p_year = LEFT(#p_alexa_date, 4)
SET #p_start_date = CONVERT(VARCHAR(10), DATEADD(wk, DATEDIFF(wk, 6, '1/1/' + #p_year) + (#p_week-1), 6), 121)
SET #p_end_date = CONVERT(VARCHAR(10), DATEADD(wk, DATEDIFF(wk, 5, '1/1/' + #p_year) + (#p_week-1), 5), 121)
END
From there you can do things like this in SQL. FYI
WHERE (ExhVenuesXrefs.BeginISODate <= #p_start_date)
AND (ExhVenuesXrefs.EndISODate >= #p_end_date)

Related

Exporting to Excel with Condition

i am trying to Export the data to excel .
list = [{'ip': u'9.11.180.3','endpoint': u'rd2ff5-az2-1519-1520_eth1-18_vpc', 'hostname': u'RD2APIC1', 'encap': u'vlan-42', 'epg': u'19_14_140_172', 'extpaths': u'topology/pod-2/protpaths-1519-1520/pathep-[rd2ff5-az2-1519-1520_eth1-18_vpc]'},{'ip': u'14.10.5.5','endpoint': u'eth1/2','hostname': u'RD2APIC1', 'encap': u'vlan-18', 'epg': u'14_70_7_0', 'extpaths': u'topology/pod-2/paths-1511/extpaths-102/pathep-[eth1/2]'}]
My Code :
filename = self.controller + ".xls"
excel_file = xlwt.Workbook()
sheet = excel_file.add_sheet('HOSTLIST')
sheet.write(0, 0, "APIC")
sheet.write(0, 1, "VLAN")
sheet.write(0, 2, "EPG")
sheet.write(0, 3, "EndPoint")
sheet.write(0, 4, "Extpath")
for count in xrange(1, len(list) + 1):
if list[count - 1]["epg"]:
epg = list[count - 1]["epg"]
else:
epg = "UNKNOWN"
sheet.write(count, 0, list[count - 1].get("hostname","UNKNOWN"))
sheet.write(count, 1, list[count - 1].get("encap","UNKNOWN"))
sheet.write(count, 2, epg)
sheet.write(count, 3, list[count - 1].get("endpoint","UNKNOWN"))
sheet.write(count, 4, list[count - 1].get("extpaths","UNKNOWN"))
excel_file.save(filename)
Basically i need to split the "endpoint" .Need to remove the section after "_ "
in this case "endpoint - rd2ff5-az2-1519-1520_eth1-18_vpc" needs to be split as rd2ff5-az2-1519-1520and export to excel .
Any suggestion / idea ?

How to align QTextEdit text

How can I align this text? \t is not good.
What I see (image)
Expected result (image)
I had this problem once in the past. To solve the issue I used monospace font.
To get everything aligned (fixed font width) I used these lines:
// Use "monospaced" font:
// ->insure left column alignment, as for the terminal
//
QFont font("monospace");
font.setPointSize(10);
myQTextEdit->setCurrentFont(font);
from my parent widget containing a QTextEdit child widget.
this line:
QString str = QString("B%1").arg(_ui->lineEdit->text().toInt(), 3, 10, QChar('0'));
lineEdit->text() = 1 , str = B001
lineEdit->text() = 01 , str = B001
lineEdit->text() = 001 , str = B001
lineEdit->text() = 0001 , str = B001
lineEdit->text() = 12 , str = B012
lineEdit->text() = 123 , str = B123
you can adapt it for your use.
Edit based on Hyde Comment
int main(int argc, char **argv)
{
qint32 a,b,c,d,e;
a = -1;b = 1;c = -1;d = 3;
e = (a*b) + (c*d);
QString str = QString("(%1*%2) + (%3*%4) = %5").arg(a, 2, 10, QChar(' '))
.arg(b, 2, 10, QChar(' '))
.arg(c, 2, 10, QChar(' '))
.arg(d, 2, 10, QChar(' '))
.arg(e);
QTextStream(stdout) << str << endl;
a = -1;b = 2;c = -1;d = 4;
e = (a*b) + (c*d);
str = QString("(%1*%2) + (%3*%4) = %5").arg(a, 2, 10, QChar(' '))
.arg(b, 2, 10, QChar(' '))
.arg(c, 2, 10, QChar(' '))
.arg(d, 2, 10, QChar(' '))
.arg(e);
QTextStream(stdout) << str << endl;
return 0;
}
the output is:
(-1 * 1) + (-1 * 3) = -4
(-1 * 2) + (-1 * 4) = -6

Given that the first of the month is a monday, define a predicate to print the day for any date in a month using list in prolog

This way actually worked. But are there any simplified answer.
dayname(Num,Name) :-
member([Num,Name],
[[1,'Monday'],[2,'Tuesday'],[3,'Wednesday'],[4,'Thursday'],
[5,'Friday'],[6,'Saturday'],[7,'Sunday'],[8,'Monday'],
[9,'Tuesday'],[10,'Wednesday'],[11,'Thursday'],[12,'Friday'],
[13,'Saturday'],[14,'Sunday'],[15,'Monday'],[16,'Tuesday'],
[17,'Wednesday'],[18,'Thursday'],[19,'Friday'],[20,'Saturday'],
[21,'Sunday'],[22,'Monday'],[23,'Tuesday'],[24,'Wednesday'],
[25,'Thursday'],[26,'Friday'],[27,'Saturday'],[28,'Sunday'],
[29,'Monday'],[30,'Tuesday'],[31,'Monday']]).
Yes. First of all you do not need to use member/2 for facts. You can list these as facts:
dayname(1,'Monday').
dayname(2,'Tuesday').
dayname(3,'Wednesday').
dayname(4,'Thursday').
dayname(5,'Friday').
dayname(6,'Saturday').
dayname(7,'Sunday').
But now we have of course no way to obtain 'Monday' for 8. Probably the most declarative way to do this is the following clause:
:- use_module(library(clpfd)).
dayname(I,D) :-
I in 8..31,
J #= I-7,
dayname(J,D).
Putting this all together, we get:
:- use_module(library(clpfd)).
dayname(1,'Monday').
dayname(2,'Tuesday').
dayname(3,'Wednesday').
dayname(4,'Thursday').
dayname(5,'Friday').
dayname(6,'Saturday').
dayname(7,'Sunday').
dayname(I,D) :-
I in 8..31,
J #= I-7,
dayname(J,D).
We then query it in all possible ways:
?- dayname(I,D).
I = 1,
D = 'Monday' ;
I = 2,
D = 'Tuesday' ;
I = 3,
D = 'Wednesday' ;
I = 4,
D = 'Thursday' ;
I = 5,
D = 'Friday' ;
I = 6,
D = 'Saturday' ;
I = 7,
D = 'Sunday' ;
I = 8,
D = 'Monday' ;
I = 9,
D = 'Tuesday' ;
I = 10,
D = 'Wednesday' ;
I = 11,
D = 'Thursday' ;
I = 12,
D = 'Friday' ;
I = 13,
D = 'Saturday' ;
I = 14,
D = 'Sunday' ;
I = 15,
D = 'Monday' ;
I = 16,
D = 'Tuesday' ;
I = 17,
D = 'Wednesday' ;
I = 18,
D = 'Thursday' ;
I = 19,
D = 'Friday' ;
I = 20,
D = 'Saturday' ;
I = 21,
D = 'Sunday' ;
I = 22,
D = 'Monday' ;
I = 23,
D = 'Tuesday' ;
I = 24,
D = 'Wednesday' ;
I = 25,
D = 'Thursday' ;
I = 26,
D = 'Friday' ;
I = 27,
D = 'Saturday' ;
I = 28,
D = 'Sunday' ;
I = 29,
D = 'Monday' ;
I = 30,
D = 'Tuesday' ;
I = 31,
D = 'Wednesday' ;
false.
?- dayname(15,D).
D = 'Monday' ;
false.
?- dayname(I,'Thursday').
I = 4 ;
I = 11 ;
I = 18 ;
I = 25 ;
false.
?- dayname(12,'Thursday').
false.
?- dayname(11,'Thursday').
true ;
false.

Get First Date and Last Date of Current Quarter in Python?

How can i get the Current Quarter year and then First Date and last Date of Current Quarter Year in Python?
i want by importing datetime
import datetime
People look into Stack overflow need straight forward answer and which should be very simple. Which ever link you provided it having lot of Comments. SO, users has to go through all the comments to find correct answer. I am writing simple and straight forward answer.
I believe that none of the current answers are still valid in Python 3, so since this is the top hit in google for first and last day of quarter, I will provide a solution that works in Python 3 (mostly Ahmet's with // instead of /):
from datetime import date as date_class
from datetime import timedelta, datetime
def get_quarter(p_date: date_class) -> int:
return (p_date.month - 1) // 3 + 1
def get_first_day_of_the_quarter(p_date: date_class):
return datetime(p_date.year, 3 * ((p_date.month - 1) // 3) + 1, 1)
def get_last_day_of_the_quarter(p_date: date_class):
quarter = get_quarter(p_date)
return datetime(p_date.year + 3 * quarter // 12, 3 * quarter % 12 + 1, 1) + timedelta(days=-1)
assert get_quarter(datetime(year=2021, month=10, day=5).date()) == 4
assert get_quarter(datetime(year=2020, month=9, day=25).date()) == 3
assert get_quarter(datetime(year=2020, month=12, day=11).date()) == 4
assert get_quarter(datetime(year=2020, month=1, day=2).date()) == 1
assert get_first_day_of_the_quarter(datetime(2020, 10, 5).date()) == datetime(2020, 10, 1)
assert get_first_day_of_the_quarter(datetime(2020, 9, 25).date()) == datetime(2020, 7, 1)
assert get_first_day_of_the_quarter(datetime(2020, 12, 11).date()) == datetime(2020, 10, 1)
assert get_first_day_of_the_quarter(datetime(2020, 1, 2).date()) == datetime(2020, 1, 1)
assert get_last_day_of_the_quarter(datetime(2020, 10, 5).date()) == datetime(2020, 12, 31)
assert get_last_day_of_the_quarter(datetime(2020, 9, 25).date()) == datetime(2020, 9, 30)
assert get_last_day_of_the_quarter(datetime(2020, 12, 11).date()) == datetime(2020, 12, 31)
assert get_last_day_of_the_quarter(datetime(2020, 1, 2).date()) == datetime(2020, 3, 31)
assert get_last_day_of_the_quarter(datetime(2020, 5, 6).date()) == datetime(2020, 6, 30)
Having the first day is the same with #Karishh's solution. But, for the last date, Python2.7 causes a problem for fourth quarter. Because 12+1=13 and datetime does not accept 13 as a month. So you need to do some tricks to handle it.
import datetime
def get_quarter(date):
return (date.month - 1) / 3 + 1
def get_first_day_of_the_quarter(date):
quarter = get_quarter(date)
return datetime.datetime(date.year, 3 * quarter - 2, 1)
def get_last_day_of_the_quarter(date):
quarter = get_quarter(date)
month = 3 * quarter
remaining = month / 12
return datetime.datetime(date.year + remaining, month % 12 + 1, 1) + datetime.timedelta(days=-1)
Any how i found some simple solution in c# and converted it into python,
from datetime import datetime,timedelta
current_date=datetime.now()
currQuarter = (current_date.month - 1) / 3 + 1
dtFirstDay = datetime(current_date.year, 3 * currQuarter - 2, 1)
dtLastDay = datetime(current_date.year, 3 * currQuarter + 1, 1) + timedelta(days=-1)
Here's a one/two liner to get the start/end date of the current quarter.
from datetime import datetime
import math
from dateutil.relativedelta import relativedelta # requires python-dateutil
start_of_quarter = datetime(year=datetime.now().year, month=((math.floor(((datetime.now().month - 1) / 3) + 1) - 1) * 3) + 1, day=1)
end_of_quarter = start_of_quarter + relativedelta(months=3, seconds=-1)
pendulum has a much more intuitive implementation.
import pendulum
dt = pendulum.datetime(2021, 3, 23)
print(dt.first_of('quarter'))
print(dt.last_of('quarter'))
2021-01-01T00:00:00+00:00
2021-03-31T00:00:00+00:00
Building off of the answer from Krishh, but addressing several issues found:
calculating last day in Quarter 4
Wasae Shoaib's comment about raising a ValueError
TypeError with a float being passed instead of an integer
Using relativedeta instead and shifting the correctly calculated start date by three months, we end up with a much more reliable way to get at the quarter end date.
from datetime import datetime
from dateutil.relativedelta import relativedelta
current_date = datetime.now()
currQuarter = int((current_date.month - 1) / 3 + 1)
dtFirstDay = datetime(current_date.year, 3 * currQuarter - 2, 1)
dtLastDay = dtFirstDay + relativedelta(months=3, days=-1)
I did of a lot of tests to find the solution that fit my need and I will be happy if it helps someone else :
datval = fields.date.today()
if datval.month < 4 :
self.start_date = fields.date.today().replace(month=10, day=1)
self.end_date = fields.date.today().replace(month=12, day=31)
elif datval.month < 7 :
self.start_date = fields.date.today().replace(month=1, day=1)
self.end_date = fields.date.today().replace(month=3, day=31)
elif datval.month < 10 :
self.start_date = fields.date.today().replace(month=4, day=1)
self.end_date = fields.date.today().replace(month=6, day=30)
else :
self.start_date = fields.date.today().replace(month=7, day=1)
self.end_date = fields.date.today().replace(month=9, day=30)
Get start and end points for: week, month, quarter and year
https://gist.github.com/dejurin/236b398dc4b8064685702a27a3df612b
from datetime import date
from dateutil.relativedelta import relativedelta
def start_end_day(sunmon: bool = True):
today = date.today()
curr_quarter = int((today.month - 1) / 3 + 1)
dayofweek = [today.weekday(),today.isoweekday()][sunmon]
week_start = today - relativedelta(days=dayofweek)
week_end = week_start + relativedelta(days=6)
month_start = date(today.year,today.month, 1)
month_end = month_start + relativedelta(months=1, days=-1)
quarter_start = date(today.year, 3 * curr_quarter - 2, 1)
quarter_end = quarter_start + relativedelta(months=3, days=-1)
year_start = date(today.year, 1, 1)
year_end = year_start + relativedelta(years=1, days=-1)
return ((week_start,week_end),(month_start,month_end),(quarter_start,quarter_end),(year_start,year_end))
"""
Current date: 18/02/2022
"""
"""
((datetime.date(2022, 2, 13), datetime.date(2022, 2, 19)),
(datetime.date(2022, 2, 1), datetime.date(2022, 2, 28)),
(datetime.datetime(2022, 1, 1, 0, 0), datetime.datetime(2022, 3, 31, 0, 0))
(datetime.date(2022, 1, 1), datetime.date(2022, 12, 31)))
"""

Python 2.7; How to clear an entry in the GUI

I have an example code, here just for BMI index. I would like to clear the input and output fields in the GUI. It seems that i can clear the entries, but the BMI calculation is not being removed (row 79 does not seem to have an effect) (# self.text.delete(0, 'end'))
Thanks
Emin
import math
from Tkinter import *
class Application(Frame):
"""A GUI application with three buttons"""
def __init__(self, master):
"""Initialize the Frame"""
Frame.__init__(self,master)
self.grid()
self.create_widgets()
self.title = Label(self, text = "BMI index calculation")
self.title.grid(row = 0, column = 0, columnspan = 2 , sticky =W)
def create_widgets(self):
"""Create button, text and entry widgets"""
self.name = Label(self, text = "What is your name?")
self.name.grid(row = 1, column = 0, columnspan = 2 , sticky =W)
self.name_io = Entry(self)
self.name_io.grid(row = 1, column =2, sticky = W)
self.age = Label(self, text = "How old are you?")
self.age.grid(row = 2, column = 0, columnspan = 2 , sticky =W)
self.age_io = Entry(self)
self.age_io.grid(row = 2, column =2, sticky = W)
self.height = Label(self, text = "How tall are you?")
self.height.grid(row = 3, column = 0, columnspan = 2 , sticky =W)
self.height_io = Entry(self)
self.height_io.grid(row = 3, column =2, sticky = W)
self.weight = Label(self, text = "How much do you weigh in kg?")
self.weight.grid(row = 4, column = 0, columnspan = 2 , sticky =W)
self.weight_io = Entry(self)
self.weight_io.grid(row = 4, column =2, sticky = W)
self.submit_button = Button(self, text = "Calculate", command = self.reveal)
self.submit_button.grid(row = 5, column = 0, sticky = W)
self.text = Text(self, width = 40, height = 5, wrap = WORD)
self.text.grid(row = 6, column = 0, columnspan = 3, sticky = W)
self.clear_button = Button(self, text = "Clear", command = self.clear_text)
self.clear_button.grid(row = 7, column = 0, sticky = W)
def reveal(self):
"""Display message based on the password typed in"""
content_name = self.name_io.get()
content_age = float(self.age_io.get())
content_height = float(self.height_io.get())
content_weight = float(self.weight_io.get())
BMI = round((content_weight/(content_height/100)**2.),1)
underBMI = 18.5
NormalBMI = 24.9
OverweightBMI = 29.9
ObesityBMI = 30
if BMI <= underBMI:
message = content_name + ", " + "your BMI index is" + " " + str(BMI) + ", " + "you are underweight, so you need to eat!"
elif (BMI > underBMI) and (BMI <= NormalBMI):
message = content_name + ", " + "your BMI index is" + " " + str(BMI) + ", " + "your BMI is Normal"
elif (BMI > NormalBMI) and (BMI <= OverweightBMI):
message = content_name + ", " + "your BMI index is" + " " + str(BMI) + ", " + "you are Overweight - need to exercise!"
elif (BMI > OverweightBMI):
message = content_name + ", " + "your BMI index is" + " " + str(BMI) + ", " + "you are in Obesity"
self.text.insert(0.0, message)
def clear_text(self):
self.name_io.delete(0, 'end')
self.age_io.delete(0, 'end')
self.height_io.delete(0, 'end')
self.weight_io.delete(0, 'end')
# self.text.delete(0, 'end')
root = Tk()
root.title("BMI Index")
root.geometry("600x350")
app = Application(root)
root.mainloop ()
The problem is that you're giving an index that is 0.0. Text widget indexes are a string of the form line.column but you're giving it a floating point number.
The proper index for the first character is the string "1.0".
self.text.delete("1.0", 'end')
Simply
your_entry.delete(0,END)