コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pd"></param>
        /// <param name="data"></param>
        /// <param name="index"></param>
        /// <returns></returns>
        public static SeriesBase Series <T>(this Pandas pd, T[] data, IDataIndex index = null)
            where T : struct
        {
            Series series = new Series(data)
            {
                Index = index
            };

            return(series);
        }
コード例 #2
0
        public static SeriesBase Series <T>(this Pandas pd, T data, IDataIndex index = null)
        {
            Series res        = null;
            Type   type       = data.GetType();
            var    properties = type.GetProperties();
            var    nd         = properties.Select(x => x.GetValue(data)).ToArray();

            res = new Series(nd)
            {
                Index = new DataIndex(properties.Select(x => x.Name).ToArray())
            };
            return(res);
        }
コード例 #3
0
ファイル: PandasFactory.cs プロジェクト: bgkyer/Pandas.NET
        public static SeriesBase Series <T>(this Pandas pd, T data)
        {
            if (data is Array)
            {
                return(pd.Series(data as Array));
            }
            Type   type       = data.GetType();
            var    properties = type.GetProperties();
            var    nd         = properties.Select(x => x.GetValue(data)).ToArray();
            Series res        = new Series(new NDArray(nd))
            {
                Index = new DataIndex(properties.Select(x => x.Name).ToArray())
            };

            return(res);
        }
コード例 #4
0
        public static IDataFrame DataFrame <T>(this Pandas pd, IList <T> data, IList <string> index = null)
        {
            var type = typeof(T);

            if (type.FullName == "System.Object")
            {
                type = data[0].GetType();
            }
            var props      = type.GetProperties();
            var columnSize = props.Count();
            var rowSize    = data.Count();
            var nd         = new NDArray(typeof(object), new Shape(rowSize, columnSize));

            for (var i = 0; i < rowSize; i++)
            {
                for (var p = 0; p < columnSize; p++)
                {
                    nd[i, p] = props[p].GetValue(data[i]);
                }
            }
            return(pd.DataFrame(nd, index, props.Select(x => x.Name).ToArray(), typeof(object)));
        }
コード例 #5
0
 public static IDataFrame DataFrame <TIndex>(this Pandas pd, IDictionary <string, NDArray> data, IList <TIndex> index = null)
 {
     return(new DataFrame <TIndex>(data, index));
 }
コード例 #6
0
 public static IDataFrame DataFrame(this Pandas pd, IDictionary <string, NDArray> data, IList <string> index = null)
 {
     return(pd.DataFrame <string>(data, index));
 }
コード例 #7
0
 public static IDataFrame DataFrame(this Pandas pd, NDArray data, IList <string> index, IList <string> columns, Type dtype)
 {
     return(pd.DataFrame <string>(data, index, columns, dtype));
 }
コード例 #8
0
        public static SeriesBase Series(this Pandas pd, NDArray data)
        {
            Series series = new Series(data);

            return(series);
        }
コード例 #9
0
 /// <summary>
 /// Read a comma-separated values (csv) file into DataFrame.
 /// </summary>
 /// <param name="pd"></param>
 /// <param name="filepath_or_buffer"></param>
 /// <param name="sep"></param>
 /// <param name="names"></param>
 /// <returns></returns>
 public static IDataFrame read_csv(this Pandas pd, string filepath, string sep = ",", string[] names = null)
 {
     throw new NotImplementedException();
 }