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 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

ggplot2 How to put at bottom the x axis title?

I have this dataframe: Control Stress days sd_control sd_stress X1 -0.2866667 -0.2833333 X1 0.11846237 0.05773503 X2 -0.2566667 -1.0333333 X2 0.08144528 0.15275252 X3 -0.4766667 -1.4500000 X3 0.09291573 0.10000000 X4 -0.4900000 -1.2766667 X4 0.21517435 0.22501852 X5 -0.4600000 -1.2666667 X5 0.07549834 0.40722639 X6 -0.2633333 -1.0833333 X6 0.12662280 0.10408330 X7 -0.2833333 -1.0333333 X7 0.03511885 0.07767453 Based on this data […]

Categories
Mastering Development

cannot arrange numbers into shape (n,n) matrix

I have the following code that generates a fractal image, the problem is how to reconstruct numbers to be a matrix. from PIL import Image from pylab import * from numpy import NaN import numpy as np import matplotlib.pyplot as plt def julia(C): X = arange(-1.5, 1.5, 0.05) Y = arange(-1.5, 1.5, 0.05) pixel = […]

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

geopandas: from a column of coordinate list to geometry

I have a DataFrame which has a column of coordinates list looks like the following: I want to make this DataFrame a GeoPandas DataFrame with a geometry column. One way for doing this is to create two lists representing latitude and longitude and store the first and second element from the coors column to latitude […]

Categories
Mastering Development

How to remove outliers from multiple columns in pyspark using mean and standard deviation

I have the below data frame and I want to remove outliers from defined columns. In the below example price and income. Outliers should be removed for each group of data. In this example its ‘cd’ and ‘segment’ columns. Outliers should be removed based 5 standard deviations. data = [ (‘a’, ‘1’,20,10), (‘a’, ‘1’,30,16), (‘a’, […]

Categories
Mastering Development

Error in guess(varying) when trying to fit an mlogit in R

I am struggling to reproduce a choice modeling mlogit example with willingness to pay. When I try to fit the first mlogit, I get an error that says "Error in guess(varying) : failed to guess time-varying variables from their names In addition: Warning message: In dfidx::dfidx(data = data, dfa$idx, drop.index = dfa$drop.index, : the levels […]

Categories
CMS Magento Mastering Development

Invoice pdf add global amount

I want to add the global amount field in the text that I added in the invoice pdf. public function insertConditions($page) { $page->drawLine(25, $this->y, 570, $this->y); $this->y -= 25; $page->drawText(Mage::helper(‘sales’)->__(‘The order amount with a value [global amount] of has already been paid..’), 35, $this->y, ‘UTF-8’); }

Categories
Mastering Development

function(return array of “column” in a Javascript/Json Object)

I’ve got this object var list = {"selection1": [ {"answers": [1, 4, 5, 7]}, {"answers": [4, 3, 2, 1]}, {"answers": [10, 22, 12, 34]}, ], "selection2": [ {"answers": [31, 34, 35, 37]}, {"answers": [44, 43, 42, 41]}, {"answers": [20, 42, 22, 54]}, ]}; and I want to return a desired column by calling function(1, list, […]