diff --git a/index.html b/index.html index d3b7899..578d9f5 100644 --- a/index.html +++ b/index.html @@ -255,6 +255,7 @@
+
@@ -262,6 +263,11 @@
+ + +
+ diff --git a/script.js b/script.js index 02c5505..56f5229 100644 --- a/script.js +++ b/script.js @@ -302,6 +302,8 @@ const columnWrangleModify = (stat) => { } // Selection and indexing +let selectionGrouping = document.getElementById("selectionGrouping"); + const individualSelection = () => { if (variable.value === "") { return alert("Please enter a variable name in the 'variable' field, in the 'Load data' section."); @@ -503,3 +505,45 @@ const numberSelectionDoubleDiffIsIn = () => { // Dates let dateColumn = document.getElementById("dateColumn"); + +const date = () => { + if (variable.value === "") { + return alert("Please enter a variable name in the 'variable' field, in the 'Load data' section."); + } else if (dateColumn.value === "") { + return alert("Please enter a date in the 'date column' field, in the 'Date' section."); + } else { + document.editor.textbox.value+="\n" + variable.value + "['" + dateColumn.value + "'] = " + variable.value + "[['Year', 'Month', 'Day']].apply(lambda x: '{}-{}-{}'.format(x[0], x[1], x[2]), axis=1)"; + } +} + +const dateDiff = () => { + if (variable.value === "") { + return alert("Please enter a variable name in the 'variable' field, in the 'Load data' section."); + } else if (dateNewColumn.value === '') { + return alert("Please enter a new column name in the 'new column' field, in the 'Date' section."); + } else if (dateColumn.value.split(",").length !== 2) { + return alert("Please enter two dates in the 'date column' field, in the 'Date' section."); + } else { + document.editor.textbox.value+="\n" + variable.value + "['" + dateNewColumn.value + "'] = " + variable.value + "[[" + dateColumn.value.split(',').map(el => `'${el.replace(' ', '')}'`) + "]].apply(lambda x: (x[1] - x[0]).days, axis=1)"; + } +} + +const parseDate = () => { + if (variable.value === "") { + return alert("Please enter a variable name in the 'variable' field, in the 'Load data' section."); + } else if (dateColumn.value === "") { + return alert("Please enter a date in the 'date column' field, in the 'Date' section."); + } else { + document.editor.textbox.value+="\n" + variable.value + "['" + dateColumn.value + "'] = pd.to_datetime(" + variable.value + "['" + dateColumn.value + "'])"; + } +} + +const lineDate = () => { + if (variable.value === "") { + return alert("Please enter a variable name in the 'variable' field, in the 'Load data' section."); + } else if (dateColumn.value === '') { + return alert("Please enter a date in the 'date column' field, in the 'Date' section."); + } else { + document.editor.textbox.value+="\n" + variable.value + "['" + dateColumn.value + "'].value_counts().plot(kind='line', figsize=(14,6))"; + } +} diff --git a/styles.css b/styles.css index 92e3489..fcd898b 100644 --- a/styles.css +++ b/styles.css @@ -95,6 +95,10 @@ td { border-color: chocolate; } +.btn-primary, .btn-success, .btn-data { + color: white; +} + .hide { display: none; } @@ -115,3 +119,7 @@ input { input:not([type:"button"]) { border-color: black; } + +#selectionPercentage { + width: 85px; +}