/// <summary>
        /// Callback method for DataBridge mechanism.
        /// This callback only gets called when
        ///     - The AST is executed
        ///     - After the BuildOutputAST function is executed
        ///     - The AST is fully built
        /// </summary>
        /// <param name="data">The data passed through the data bridge.</param>
        private void DataBridgeCallback(object data)
        {
            // Grab input data which always returned as an ArrayList
            var inputs = data as ArrayList;

            // Each of the list inputs are also returned as ArrayLists
            Dictionary <string, object> dataframeDictionary = DictionaryHelpers.ToCDictionary(inputs[0] as DesignScript.Builtin.Dictionary);

            DataframeDictionary = dataframeDictionary;
            // Notify UI the data has been modified
            RaisePropertyChanged("DataUpdated");
        }
Пример #2
0
        public static DataFrame ByDictionary(Dictionary dataDictionary)
        {
            var    dict    = DictionaryHelpers.ToCDictionary(dataDictionary);
            string jsonStr = JsonConvert.SerializeObject(dict, Formatting.None);

            // Build argument JSON objec
            dynamic arguments = new JObject();

            arguments.jsonStr = jsonStr;

            string dataframeJson = DynamoPandas.Pandamo.PythonRestCall
                                   .webUriPostCaller(PythonConstants.webUri + "api/create_dataframe/by_dict/", arguments);
            DataFrame df = new DataFrame(dataframeJson);

            return(df);
        }
Пример #3
0
        /// <summary>
        /// Callback method for DataBridge mechanism.
        /// This callback only gets called when
        ///     - The AST is executed
        ///     - After the BuildOutputAST function is executed
        ///     - The AST is fully built
        /// </summary>
        /// <param name="data">The data passed through the data bridge.</param>
        private void DataBridgeCallback(object data)
        {
            // Grab input data which always returned as an ArrayList
            var inputs = data as ArrayList;

            if (inputs[0] == null)
            {
                return;
            }

            // Each of the list inputs are also returned as ArrayLists
            Dictionary <string, object> dataframeDictionary = DictionaryHelpers.ToCDictionary(inputs[0] as DesignScript.Builtin.Dictionary);

            DataframeDictionary = dataframeDictionary;

            DataTable = DataTabelFromDictionary(DataframeDictionary);
        }
Пример #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="dataframe"></param>
        /// <param name="columns"></param>
        /// <returns></returns>
        public static DataFrame DropOutliers(DataFrame dataframe, DesignScript.Builtin.Dictionary zValues, int standardDeviation)
        {
            string jsonStr = dataframe.InternalDfJson;
            Dictionary <string, object> zValsDict = DictionaryHelpers.ToCDictionary(zValues);

            // Build argument JSON objec
            dynamic arguments = new JObject();

            arguments.jsonStr            = jsonStr;
            arguments.z_values           = JToken.FromObject(zValsDict);
            arguments.standard_deviation = JToken.FromObject(standardDeviation);

            string dataframeJson = DynamoPandas.Pandamo.PythonRestCall
                                   .webUriPostCaller(PythonConstants.webUri + UrlPrefix + "/drop_outliers/", arguments);
            DataFrame df = new DataFrame(dataframeJson);

            return(df);
        }