Categories
Mastering Development

How to Un-Sort The legends in the graph in R?

I am not an expert in R. I am having an issue, the legends are sorted alphabetically. I cannot arrange them manually because I have 87 patients and each patient has 300 days and the status (category) changes every day so i want to plot the graph exactly like it has in the source. ggplot(data […]

Categories
Mastering Development

Why D3 adds element outside of the body

I am trying to add elements inside svg using the D3 data enter then append function. D3 adds circles outside of the body. I am unable to figure out how to bring circles inside svg. Sample HTML: <html> <script src=’https://d3js.org/d3.v5.min.js’></script> <body> <svg width=500 height=500></svg> </body> <script> var data = [4,8,15,16,23,42]; var svgContainer = d3.select(‘body’).selectAll(‘svg’); svgContainer.data(data).enter().append("circle"); […]

Categories
Mastering Development System & Network

How to Convert Arrays in SQL to Int

Can someone let me know how to convert/replace/remove array datatypes from my tables into Integers. I am trying to convert/replace the Arrays in columns, Monday, Tuesday, Wednesday, Thursday, Friday to integers I have used the following code on the Friday field: SELECT CONVERT(INT, consumersearchtest.Friday) AS FridayFROM dbo.consumersearchtest But I get the following error: 1 Conversion […]

Categories
Mastering Development

How to extract row before and after when flag change from 0 to 1

I have one dataframe , i want to extract 2 rows before flag change from 0 to one and get row where value ‘B’ is minimum , also extract two rows after flag 1 and get row with minimum value of ‘B’ df=pd.DataFrame({‘A’:[1,3,4,7,8,11,1,15,20,15,16,87], ‘B’:[1,3,4,6,8,11,1,19,20,15,16,87], ‘flag’:[0,0,0,0,1,1,1,0,0,0,0,0]}) df_out=pd.DataFrame({‘A’:[4,1], ‘B’:[4,1], ‘flag’:[0,1]})

Categories
Mastering Development

Can someone please explain some things related to the for.Each() method?

I’m learning Javascript and at the moment just going through all the little chapters in w3schools about it. Even though I’ve been having a mostly good experience, sometimes the explanations are not thorough enough and I am left confused. My problem wasn’t the forEach method itself, but instead what came along with it. Here I […]

Categories
Mastering Development

Search and process data from multi-index DataFrames

I have two dataframes df2, with the payment statistics (that have the probability of the client pay a certain debt) and df3 with new clients data. import pandas as pd d = {‘City’: [‘Tokyo’,’Tokyo’,’Lisbon’,’Tokyo’,’Tokyo’,’Lisbon’,’Lisbon’,’Lisbon’,’Tokyo’,’Lisbon’,’Tokyo’,’Tokyo’,’Tokyo’,’Lisbon’,’Tokyo’,’Tokyo’,’Lisbon’,’Lisbon’,’Lisbon’,’Tokyo’,’Lisbon’,’Tokyo’], ‘Card’: [‘Visa’,’Visa’,’Master Card’,’Master Card’,’Visa’,’Master Card’,’Visa’,’Visa’,’Master Card’,’Visa’,’Master Card’,’Visa’,’Visa’,’Master Card’,’Master Card’,’Visa’,’Master Card’,’Visa’,’Visa’,’Master Card’,’Visa’,’Master Card’], ‘Colateral’:[‘Yes’,’No’,’Yes’,’No’,’No’,’No’,’No’,’Yes’,’Yes’,’No’,’Yes’,’Yes’,’No’,’Yes’,’No’,’No’,’No’,’Yes’,’Yes’,’No’,’No’,’No’], ‘Client Number’:[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22], ‘DebtPaid’:[0.8,0.1,0.5,0.30,0,0.2,0.4,1,0.60,1,0.5,0.2,0,0.3,0,0,0.2,0,0.1,0.70,0.5,0.1]} df = pd.DataFrame(data=d) df2=df.groupby([‘City’,’Card’,’Colateral’])[‘DebtPaid’].\ value_counts(bins=[-0.001,0,0.25,0.5,0.75,1,1.001,2],normalize=True) […]

Categories
Mastering Development

How do i join 4 tables in sql

Hi there I am a beginner in SQL coding and recently got an assignment from my teacher that I am not too sure how to do. If someone could help me by explaining what to do and how to do it. The assignment is: As we have found the limitation of the 3 table system […]

Categories
Database Development

SQL Server Audit Records Non-Committed Deletes

I have a table with a trigger as follows: CREATE TABLE AuditTable ( RecordTime DATETIME, RecordDetail NVARCHAR(100) ); — trigger to block deletes and updates CREATE TRIGGER TRG_Block_Deletes_and_updates ON AuditTable INSTEAD OF DELETE, UPDATE AS SET NOCOUNT OFF; RAISERROR (‘ERROR – Deletes and Updates are not allowed on this table’,16,1); GO The idea of the […]

Categories
Mastering Development

Using csv.DictWriter to write a dictionary’s {‘key’:value} pairs into a .csv file and get ” ValueError: dict contains fields not in fieldnames: ‘

I am using Bash to generate the output of a python script. A dictionary in Bash looks like following, which I found very confusing: error = [(‘Connection to DB failed’, 14), (‘Permission denied while closing ticket’, 11), (‘The ticket was modified while updating’, 10), ("Ticket doesn’t exist", 8), (‘Timeout while retrieving information’, 16), (‘Tried to […]

Categories
Mastering Development

Why return self.head(x.view(x.size(0), -1)) in the nn.Module for pyTorch reinforcement learning example

I understand that the balancing the pole example requires 2 outputs. Reinforcement Learning (DQN) Tutorial Here is the output for self.head print (‘x’,self.head) x = Linear(in_features=512, out_features=2, bias=True) When I run the epochs below is the outputs: print (self.head(x.view(x.size(0), -1))) return self.head(x.view(x.size(0), -1)) tensor([[-0.6945, -0.1930]]) tensor([[-0.0195, -0.1452]]) tensor([[-0.0906, -0.1816]]) tensor([[ 0.0631, -0.9051]]) tensor([[-0.0982, -0.5109]]) … […]