Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
package prerna.reactor.frame.py;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import prerna.ds.OwlTemporalEngineMeta;
import prerna.ds.py.PandasFrame;
import prerna.sablecc2.om.PixelDataType;
import prerna.sablecc2.om.PixelOperationType;
import prerna.sablecc2.om.nounmeta.NounMetadata;
import prerna.util.Utility;
import prerna.util.usertracking.AnalyticsTrackerHelper;
import prerna.util.usertracking.UserTrackerFactory;
public class DiscretizeReactor extends AbstractPyFrameReactor {
/**
* Discretize([{"column":"PetalLength"}, {"column":"SepalLength", "breaks":"(4.3, 5.5, 6.7, 7.9)", "labels":"(Short,Medium,Long)"},
* {"column":"PetalWidth", "breaks":"0:5*.5"}])
* Discretize({"column":"MovieBudget", "numDigits":"10"})
* Input keys:
* 1. column (required)
* 2. breaks (conditionally required - req only if labels specified) - can be one of 3 types: integer, breakpoints as a list,
* mathematical notation of range - breakpoints as a list or mathematical notation of range need to be specified in
* ascending order
* 3. labels (optional)
* 4. numDigits (optional) specifies number of digits used in formatting the break/range numbers
*
* Return format: if labels is not specified, then the discretized ranges will be wrapped with [ ] (inclusive) or () or a combination
* and contain the lower and upper range, comma separated: ex. [0, 100) aka 0 =< x < 100
*
*/
private static final String requestMap = "requestMap";
public DiscretizeReactor() {
this.keysToGet = new String[] { requestMap };
}
@Override
public NounMetadata execute() {
organizeKeys();
// get frame
PandasFrame frame = (PandasFrame) getFrame();
String dtName = frame.getName();
// get wrapper name
String wrapperFrameName = frame.getWrapperName();
OwlTemporalEngineMeta meta = this.getFrame().getMetaData();
List colNames = Arrays.asList(frame.getColumnHeaders()); // check if this is the same as R's frame.getColumnNames()
List