/*
 Navicat Premium Data Transfer

 Source Server         : 139.196.23.118
 Source Server Type    : MySQL
 Source Server Version : 50743
 Source Host           : 139.196.23.118:33063
 Source Schema         : snb_server_db

 Target Server Type    : MySQL
 Target Server Version : 50743
 File Encoding         : 65001

 Date: 07/09/2023 18:21:44
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for ab_permission
-- ----------------------------
DROP TABLE IF EXISTS `ab_permission`;
CREATE TABLE `ab_permission` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(100) NOT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE KEY `name` (`name`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=18 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;

-- ----------------------------
-- Records of ab_permission
-- ----------------------------
BEGIN;
INSERT INTO `ab_permission` VALUES (4, 'can_add');
INSERT INTO `ab_permission` VALUES (15, 'can_chart');
INSERT INTO `ab_permission` VALUES (9, 'can_delete');
INSERT INTO `ab_permission` VALUES (5, 'can_download');
INSERT INTO `ab_permission` VALUES (8, 'can_edit');
INSERT INTO `ab_permission` VALUES (16, 'can_get');
INSERT INTO `ab_permission` VALUES (7, 'can_list');
INSERT INTO `ab_permission` VALUES (6, 'can_show');
INSERT INTO `ab_permission` VALUES (1, 'can_this_form_get');
INSERT INTO `ab_permission` VALUES (2, 'can_this_form_post');
INSERT INTO `ab_permission` VALUES (3, 'can_userinfo');
INSERT INTO `ab_permission` VALUES (14, 'copyrole');
INSERT INTO `ab_permission` VALUES (17, 'def_val');
INSERT INTO `ab_permission` VALUES (13, 'menu_access');
INSERT INTO `ab_permission` VALUES (10, 'resetmypassword');
INSERT INTO `ab_permission` VALUES (11, 'resetpasswords');
INSERT INTO `ab_permission` VALUES (12, 'userinfoedit');
COMMIT;

-- ----------------------------
-- Table structure for ab_permission_view
-- ----------------------------
DROP TABLE IF EXISTS `ab_permission_view`;
CREATE TABLE `ab_permission_view` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `permission_id` int(11) DEFAULT NULL,
  `view_menu_id` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE KEY `permission_id` (`permission_id`,`view_menu_id`) USING BTREE,
  KEY `view_menu_id` (`view_menu_id`) USING BTREE,
  CONSTRAINT `ab_permission_view_ibfk_1` FOREIGN KEY (`permission_id`) REFERENCES `ab_permission` (`id`),
  CONSTRAINT `ab_permission_view_ibfk_2` FOREIGN KEY (`view_menu_id`) REFERENCES `ab_view_menu` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=119 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;

-- ----------------------------
-- Records of ab_permission_view
-- ----------------------------
BEGIN;
INSERT INTO `ab_permission_view` VALUES (1, 1, 5);
INSERT INTO `ab_permission_view` VALUES (3, 1, 6);
INSERT INTO `ab_permission_view` VALUES (5, 1, 7);
INSERT INTO `ab_permission_view` VALUES (2, 2, 5);
INSERT INTO `ab_permission_view` VALUES (4, 2, 6);
INSERT INTO `ab_permission_view` VALUES (6, 2, 7);
INSERT INTO `ab_permission_view` VALUES (7, 3, 9);
INSERT INTO `ab_permission_view` VALUES (8, 4, 9);
INSERT INTO `ab_permission_view` VALUES (19, 4, 12);
INSERT INTO `ab_permission_view` VALUES (36, 4, 23);
INSERT INTO `ab_permission_view` VALUES (40, 4, 24);
INSERT INTO `ab_permission_view` VALUES (46, 4, 27);
INSERT INTO `ab_permission_view` VALUES (52, 4, 29);
INSERT INTO `ab_permission_view` VALUES (58, 4, 30);
INSERT INTO `ab_permission_view` VALUES (65, 4, 33);
INSERT INTO `ab_permission_view` VALUES (71, 4, 35);
INSERT INTO `ab_permission_view` VALUES (77, 4, 37);
INSERT INTO `ab_permission_view` VALUES (92, 4, 45);
INSERT INTO `ab_permission_view` VALUES (98, 4, 47);
INSERT INTO `ab_permission_view` VALUES (103, 4, 48);
INSERT INTO `ab_permission_view` VALUES (108, 4, 49);
INSERT INTO `ab_permission_view` VALUES (113, 4, 50);
INSERT INTO `ab_permission_view` VALUES (9, 5, 9);
INSERT INTO `ab_permission_view` VALUES (20, 5, 12);
INSERT INTO `ab_permission_view` VALUES (10, 6, 9);
INSERT INTO `ab_permission_view` VALUES (21, 6, 12);
INSERT INTO `ab_permission_view` VALUES (38, 6, 23);
INSERT INTO `ab_permission_view` VALUES (42, 6, 24);
INSERT INTO `ab_permission_view` VALUES (48, 6, 27);
INSERT INTO `ab_permission_view` VALUES (54, 6, 29);
INSERT INTO `ab_permission_view` VALUES (60, 6, 30);
INSERT INTO `ab_permission_view` VALUES (67, 6, 33);
INSERT INTO `ab_permission_view` VALUES (73, 6, 35);
INSERT INTO `ab_permission_view` VALUES (79, 6, 37);
INSERT INTO `ab_permission_view` VALUES (84, 6, 39);
INSERT INTO `ab_permission_view` VALUES (88, 6, 42);
INSERT INTO `ab_permission_view` VALUES (91, 6, 44);
INSERT INTO `ab_permission_view` VALUES (94, 6, 45);
INSERT INTO `ab_permission_view` VALUES (100, 6, 47);
INSERT INTO `ab_permission_view` VALUES (105, 6, 48);
INSERT INTO `ab_permission_view` VALUES (110, 6, 49);
INSERT INTO `ab_permission_view` VALUES (115, 6, 50);
INSERT INTO `ab_permission_view` VALUES (11, 7, 9);
INSERT INTO `ab_permission_view` VALUES (22, 7, 12);
INSERT INTO `ab_permission_view` VALUES (29, 7, 16);
INSERT INTO `ab_permission_view` VALUES (31, 7, 18);
INSERT INTO `ab_permission_view` VALUES (33, 7, 20);
INSERT INTO `ab_permission_view` VALUES (37, 7, 23);
INSERT INTO `ab_permission_view` VALUES (41, 7, 24);
INSERT INTO `ab_permission_view` VALUES (47, 7, 27);
INSERT INTO `ab_permission_view` VALUES (53, 7, 29);
INSERT INTO `ab_permission_view` VALUES (59, 7, 30);
INSERT INTO `ab_permission_view` VALUES (66, 7, 33);
INSERT INTO `ab_permission_view` VALUES (72, 7, 35);
INSERT INTO `ab_permission_view` VALUES (78, 7, 37);
INSERT INTO `ab_permission_view` VALUES (83, 7, 39);
INSERT INTO `ab_permission_view` VALUES (87, 7, 42);
INSERT INTO `ab_permission_view` VALUES (90, 7, 44);
INSERT INTO `ab_permission_view` VALUES (93, 7, 45);
INSERT INTO `ab_permission_view` VALUES (99, 7, 47);
INSERT INTO `ab_permission_view` VALUES (104, 7, 48);
INSERT INTO `ab_permission_view` VALUES (109, 7, 49);
INSERT INTO `ab_permission_view` VALUES (114, 7, 50);
INSERT INTO `ab_permission_view` VALUES (12, 8, 9);
INSERT INTO `ab_permission_view` VALUES (23, 8, 12);
INSERT INTO `ab_permission_view` VALUES (39, 8, 23);
INSERT INTO `ab_permission_view` VALUES (43, 8, 24);
INSERT INTO `ab_permission_view` VALUES (49, 8, 27);
INSERT INTO `ab_permission_view` VALUES (55, 8, 29);
INSERT INTO `ab_permission_view` VALUES (61, 8, 30);
INSERT INTO `ab_permission_view` VALUES (68, 8, 33);
INSERT INTO `ab_permission_view` VALUES (74, 8, 35);
INSERT INTO `ab_permission_view` VALUES (80, 8, 37);
INSERT INTO `ab_permission_view` VALUES (95, 8, 45);
INSERT INTO `ab_permission_view` VALUES (101, 8, 47);
INSERT INTO `ab_permission_view` VALUES (106, 8, 48);
INSERT INTO `ab_permission_view` VALUES (111, 8, 49);
INSERT INTO `ab_permission_view` VALUES (116, 8, 50);
INSERT INTO `ab_permission_view` VALUES (13, 9, 9);
INSERT INTO `ab_permission_view` VALUES (24, 9, 12);
INSERT INTO `ab_permission_view` VALUES (50, 9, 27);
INSERT INTO `ab_permission_view` VALUES (57, 9, 29);
INSERT INTO `ab_permission_view` VALUES (62, 9, 30);
INSERT INTO `ab_permission_view` VALUES (69, 9, 33);
INSERT INTO `ab_permission_view` VALUES (75, 9, 35);
INSERT INTO `ab_permission_view` VALUES (81, 9, 37);
INSERT INTO `ab_permission_view` VALUES (96, 9, 45);
INSERT INTO `ab_permission_view` VALUES (102, 9, 47);
INSERT INTO `ab_permission_view` VALUES (107, 9, 48);
INSERT INTO `ab_permission_view` VALUES (112, 9, 49);
INSERT INTO `ab_permission_view` VALUES (117, 9, 50);
INSERT INTO `ab_permission_view` VALUES (14, 10, 9);
INSERT INTO `ab_permission_view` VALUES (15, 11, 9);
INSERT INTO `ab_permission_view` VALUES (16, 12, 9);
INSERT INTO `ab_permission_view` VALUES (17, 13, 10);
INSERT INTO `ab_permission_view` VALUES (18, 13, 11);
INSERT INTO `ab_permission_view` VALUES (26, 13, 13);
INSERT INTO `ab_permission_view` VALUES (28, 13, 15);
INSERT INTO `ab_permission_view` VALUES (30, 13, 17);
INSERT INTO `ab_permission_view` VALUES (32, 13, 19);
INSERT INTO `ab_permission_view` VALUES (34, 13, 21);
INSERT INTO `ab_permission_view` VALUES (44, 13, 25);
INSERT INTO `ab_permission_view` VALUES (45, 13, 26);
INSERT INTO `ab_permission_view` VALUES (51, 13, 28);
INSERT INTO `ab_permission_view` VALUES (63, 13, 31);
INSERT INTO `ab_permission_view` VALUES (64, 13, 32);
INSERT INTO `ab_permission_view` VALUES (70, 13, 34);
INSERT INTO `ab_permission_view` VALUES (76, 13, 36);
INSERT INTO `ab_permission_view` VALUES (82, 13, 38);
INSERT INTO `ab_permission_view` VALUES (85, 13, 40);
INSERT INTO `ab_permission_view` VALUES (86, 13, 41);
INSERT INTO `ab_permission_view` VALUES (89, 13, 43);
INSERT INTO `ab_permission_view` VALUES (97, 13, 46);
INSERT INTO `ab_permission_view` VALUES (118, 13, 51);
INSERT INTO `ab_permission_view` VALUES (25, 14, 12);
INSERT INTO `ab_permission_view` VALUES (27, 15, 14);
INSERT INTO `ab_permission_view` VALUES (35, 16, 22);
INSERT INTO `ab_permission_view` VALUES (56, 17, 29);
COMMIT;

-- ----------------------------
-- Table structure for ab_permission_view_role
-- ----------------------------
DROP TABLE IF EXISTS `ab_permission_view_role`;
CREATE TABLE `ab_permission_view_role` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `permission_view_id` int(11) DEFAULT NULL,
  `role_id` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE KEY `permission_view_id` (`permission_view_id`,`role_id`) USING BTREE,
  KEY `role_id` (`role_id`) USING BTREE,
  CONSTRAINT `ab_permission_view_role_ibfk_1` FOREIGN KEY (`permission_view_id`) REFERENCES `ab_permission_view` (`id`),
  CONSTRAINT `ab_permission_view_role_ibfk_2` FOREIGN KEY (`role_id`) REFERENCES `ab_role` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=119 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;

-- ----------------------------
-- Records of ab_permission_view_role
-- ----------------------------
BEGIN;
INSERT INTO `ab_permission_view_role` VALUES (1, 1, 1);
INSERT INTO `ab_permission_view_role` VALUES (2, 2, 1);
INSERT INTO `ab_permission_view_role` VALUES (3, 3, 1);
INSERT INTO `ab_permission_view_role` VALUES (4, 4, 1);
INSERT INTO `ab_permission_view_role` VALUES (5, 5, 1);
INSERT INTO `ab_permission_view_role` VALUES (6, 6, 1);
INSERT INTO `ab_permission_view_role` VALUES (7, 7, 1);
INSERT INTO `ab_permission_view_role` VALUES (8, 8, 1);
INSERT INTO `ab_permission_view_role` VALUES (9, 9, 1);
INSERT INTO `ab_permission_view_role` VALUES (10, 10, 1);
INSERT INTO `ab_permission_view_role` VALUES (11, 11, 1);
INSERT INTO `ab_permission_view_role` VALUES (12, 12, 1);
INSERT INTO `ab_permission_view_role` VALUES (13, 13, 1);
INSERT INTO `ab_permission_view_role` VALUES (14, 14, 1);
INSERT INTO `ab_permission_view_role` VALUES (15, 15, 1);
INSERT INTO `ab_permission_view_role` VALUES (16, 16, 1);
INSERT INTO `ab_permission_view_role` VALUES (17, 17, 1);
INSERT INTO `ab_permission_view_role` VALUES (18, 18, 1);
INSERT INTO `ab_permission_view_role` VALUES (19, 19, 1);
INSERT INTO `ab_permission_view_role` VALUES (20, 20, 1);
INSERT INTO `ab_permission_view_role` VALUES (21, 21, 1);
INSERT INTO `ab_permission_view_role` VALUES (22, 22, 1);
INSERT INTO `ab_permission_view_role` VALUES (23, 23, 1);
INSERT INTO `ab_permission_view_role` VALUES (24, 24, 1);
INSERT INTO `ab_permission_view_role` VALUES (25, 25, 1);
INSERT INTO `ab_permission_view_role` VALUES (26, 26, 1);
INSERT INTO `ab_permission_view_role` VALUES (27, 27, 1);
INSERT INTO `ab_permission_view_role` VALUES (28, 28, 1);
INSERT INTO `ab_permission_view_role` VALUES (29, 29, 1);
INSERT INTO `ab_permission_view_role` VALUES (30, 30, 1);
INSERT INTO `ab_permission_view_role` VALUES (31, 31, 1);
INSERT INTO `ab_permission_view_role` VALUES (32, 32, 1);
INSERT INTO `ab_permission_view_role` VALUES (33, 33, 1);
INSERT INTO `ab_permission_view_role` VALUES (34, 34, 1);
INSERT INTO `ab_permission_view_role` VALUES (35, 35, 1);
INSERT INTO `ab_permission_view_role` VALUES (36, 36, 1);
INSERT INTO `ab_permission_view_role` VALUES (37, 37, 1);
INSERT INTO `ab_permission_view_role` VALUES (38, 38, 1);
INSERT INTO `ab_permission_view_role` VALUES (39, 39, 1);
INSERT INTO `ab_permission_view_role` VALUES (40, 40, 1);
INSERT INTO `ab_permission_view_role` VALUES (41, 41, 1);
INSERT INTO `ab_permission_view_role` VALUES (42, 42, 1);
INSERT INTO `ab_permission_view_role` VALUES (43, 43, 1);
INSERT INTO `ab_permission_view_role` VALUES (44, 44, 1);
INSERT INTO `ab_permission_view_role` VALUES (45, 45, 1);
INSERT INTO `ab_permission_view_role` VALUES (46, 46, 1);
INSERT INTO `ab_permission_view_role` VALUES (47, 47, 1);
INSERT INTO `ab_permission_view_role` VALUES (48, 48, 1);
INSERT INTO `ab_permission_view_role` VALUES (49, 49, 1);
INSERT INTO `ab_permission_view_role` VALUES (50, 50, 1);
INSERT INTO `ab_permission_view_role` VALUES (51, 51, 1);
INSERT INTO `ab_permission_view_role` VALUES (52, 52, 1);
INSERT INTO `ab_permission_view_role` VALUES (53, 53, 1);
INSERT INTO `ab_permission_view_role` VALUES (54, 54, 1);
INSERT INTO `ab_permission_view_role` VALUES (55, 55, 1);
INSERT INTO `ab_permission_view_role` VALUES (56, 56, 1);
INSERT INTO `ab_permission_view_role` VALUES (57, 57, 1);
INSERT INTO `ab_permission_view_role` VALUES (58, 58, 1);
INSERT INTO `ab_permission_view_role` VALUES (59, 59, 1);
INSERT INTO `ab_permission_view_role` VALUES (60, 60, 1);
INSERT INTO `ab_permission_view_role` VALUES (61, 61, 1);
INSERT INTO `ab_permission_view_role` VALUES (62, 62, 1);
INSERT INTO `ab_permission_view_role` VALUES (63, 63, 1);
INSERT INTO `ab_permission_view_role` VALUES (64, 64, 1);
INSERT INTO `ab_permission_view_role` VALUES (65, 65, 1);
INSERT INTO `ab_permission_view_role` VALUES (66, 66, 1);
INSERT INTO `ab_permission_view_role` VALUES (67, 67, 1);
INSERT INTO `ab_permission_view_role` VALUES (68, 68, 1);
INSERT INTO `ab_permission_view_role` VALUES (69, 69, 1);
INSERT INTO `ab_permission_view_role` VALUES (70, 70, 1);
INSERT INTO `ab_permission_view_role` VALUES (71, 71, 1);
INSERT INTO `ab_permission_view_role` VALUES (72, 72, 1);
INSERT INTO `ab_permission_view_role` VALUES (73, 73, 1);
INSERT INTO `ab_permission_view_role` VALUES (74, 74, 1);
INSERT INTO `ab_permission_view_role` VALUES (75, 75, 1);
INSERT INTO `ab_permission_view_role` VALUES (76, 76, 1);
INSERT INTO `ab_permission_view_role` VALUES (77, 77, 1);
INSERT INTO `ab_permission_view_role` VALUES (78, 78, 1);
INSERT INTO `ab_permission_view_role` VALUES (79, 79, 1);
INSERT INTO `ab_permission_view_role` VALUES (80, 80, 1);
INSERT INTO `ab_permission_view_role` VALUES (81, 81, 1);
INSERT INTO `ab_permission_view_role` VALUES (82, 82, 1);
INSERT INTO `ab_permission_view_role` VALUES (83, 83, 1);
INSERT INTO `ab_permission_view_role` VALUES (84, 84, 1);
INSERT INTO `ab_permission_view_role` VALUES (85, 85, 1);
INSERT INTO `ab_permission_view_role` VALUES (86, 86, 1);
INSERT INTO `ab_permission_view_role` VALUES (87, 87, 1);
INSERT INTO `ab_permission_view_role` VALUES (88, 88, 1);
INSERT INTO `ab_permission_view_role` VALUES (89, 89, 1);
INSERT INTO `ab_permission_view_role` VALUES (90, 90, 1);
INSERT INTO `ab_permission_view_role` VALUES (91, 91, 1);
INSERT INTO `ab_permission_view_role` VALUES (92, 92, 1);
INSERT INTO `ab_permission_view_role` VALUES (93, 93, 1);
INSERT INTO `ab_permission_view_role` VALUES (94, 94, 1);
INSERT INTO `ab_permission_view_role` VALUES (95, 95, 1);
INSERT INTO `ab_permission_view_role` VALUES (96, 96, 1);
INSERT INTO `ab_permission_view_role` VALUES (97, 97, 1);
INSERT INTO `ab_permission_view_role` VALUES (98, 98, 1);
INSERT INTO `ab_permission_view_role` VALUES (99, 99, 1);
INSERT INTO `ab_permission_view_role` VALUES (100, 100, 1);
INSERT INTO `ab_permission_view_role` VALUES (101, 101, 1);
INSERT INTO `ab_permission_view_role` VALUES (102, 102, 1);
INSERT INTO `ab_permission_view_role` VALUES (103, 103, 1);
INSERT INTO `ab_permission_view_role` VALUES (104, 104, 1);
INSERT INTO `ab_permission_view_role` VALUES (105, 105, 1);
INSERT INTO `ab_permission_view_role` VALUES (106, 106, 1);
INSERT INTO `ab_permission_view_role` VALUES (107, 107, 1);
INSERT INTO `ab_permission_view_role` VALUES (108, 108, 1);
INSERT INTO `ab_permission_view_role` VALUES (109, 109, 1);
INSERT INTO `ab_permission_view_role` VALUES (110, 110, 1);
INSERT INTO `ab_permission_view_role` VALUES (111, 111, 1);
INSERT INTO `ab_permission_view_role` VALUES (112, 112, 1);
INSERT INTO `ab_permission_view_role` VALUES (113, 113, 1);
INSERT INTO `ab_permission_view_role` VALUES (114, 114, 1);
INSERT INTO `ab_permission_view_role` VALUES (115, 115, 1);
INSERT INTO `ab_permission_view_role` VALUES (116, 116, 1);
INSERT INTO `ab_permission_view_role` VALUES (117, 117, 1);
INSERT INTO `ab_permission_view_role` VALUES (118, 118, 1);
COMMIT;

-- ----------------------------
-- Table structure for ab_register_user
-- ----------------------------
DROP TABLE IF EXISTS `ab_register_user`;
CREATE TABLE `ab_register_user` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `first_name` varchar(64) NOT NULL,
  `last_name` varchar(64) NOT NULL,
  `username` varchar(64) NOT NULL,
  `password` varchar(256) DEFAULT NULL,
  `email` varchar(64) NOT NULL,
  `registration_date` datetime DEFAULT NULL,
  `registration_hash` varchar(256) DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE KEY `username` (`username`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;

-- ----------------------------
-- Records of ab_register_user
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for ab_role
-- ----------------------------
DROP TABLE IF EXISTS `ab_role`;
CREATE TABLE `ab_role` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(64) NOT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE KEY `name` (`name`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;

-- ----------------------------
-- Records of ab_role
-- ----------------------------
BEGIN;
INSERT INTO `ab_role` VALUES (1, 'Admin');
INSERT INTO `ab_role` VALUES (2, 'Public');
COMMIT;

-- ----------------------------
-- Table structure for ab_user
-- ----------------------------
DROP TABLE IF EXISTS `ab_user`;
CREATE TABLE `ab_user` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `first_name` varchar(64) NOT NULL,
  `last_name` varchar(64) NOT NULL,
  `username` varchar(64) NOT NULL,
  `password` varchar(256) DEFAULT NULL,
  `active` tinyint(1) DEFAULT NULL,
  `email` varchar(64) NOT NULL,
  `last_login` datetime DEFAULT NULL,
  `login_count` int(11) DEFAULT NULL,
  `fail_login_count` int(11) DEFAULT NULL,
  `created_on` datetime DEFAULT NULL,
  `changed_on` datetime DEFAULT NULL,
  `created_by_fk` int(11) DEFAULT NULL,
  `changed_by_fk` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE KEY `username` (`username`) USING BTREE,
  UNIQUE KEY `email` (`email`) USING BTREE,
  KEY `created_by_fk` (`created_by_fk`) USING BTREE,
  KEY `changed_by_fk` (`changed_by_fk`) USING BTREE,
  CONSTRAINT `ab_user_ibfk_1` FOREIGN KEY (`created_by_fk`) REFERENCES `ab_user` (`id`),
  CONSTRAINT `ab_user_ibfk_2` FOREIGN KEY (`changed_by_fk`) REFERENCES `ab_user` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;

-- ----------------------------
-- Records of ab_user
-- ----------------------------
BEGIN;
INSERT INTO `ab_user` VALUES (1, 'smart', 'notebook', 'snb_admin', 'pbkdf2:sha256:260000$4U0r7fbWlZH5ov3M$992dc1ea90bb21e074f050236e591747a4c46f392697bdc51dd001ba198b3144', 1, 'wangxinyi@smartnotebook.tech', '2023-08-14 08:41:05', 83, 0, '2022-11-21 13:07:34', '2022-11-21 13:07:34', NULL, NULL);
INSERT INTO `ab_user` VALUES (2, 'user_second_name', 'user_first_name', 'user_Admin_test', 'pbkdf2:sha256:260000$zNIIvVS3jvXY0mmK$3ed493f348dcbb99d593a8570297f1026384c5918e06c35bd2b0c984d4ebf956', 1, '@qq.com', '2022-11-28 03:09:19', 3, 0, '2022-11-28 02:53:40', '2022-12-05 03:49:05', 1, 1);
INSERT INTO `ab_user` VALUES (3, 'user_second_name', 'user_first_name', 'user_public_test', 'pbkdf2:sha256:260000$IO60S0J3FtKKnhYe$d1c8b57b027c5c5f88bffe2bc7049fafe22bac620ee9830c443bbd6b605198d9', 1, '111222333', '2022-11-28 03:04:24', 1, 0, '2022-11-28 03:01:14', '2022-11-28 03:01:14', 2, 2);
COMMIT;

-- ----------------------------
-- Table structure for ab_user_role
-- ----------------------------
DROP TABLE IF EXISTS `ab_user_role`;
CREATE TABLE `ab_user_role` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) DEFAULT NULL,
  `role_id` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE KEY `user_id` (`user_id`,`role_id`) USING BTREE,
  KEY `role_id` (`role_id`) USING BTREE,
  CONSTRAINT `ab_user_role_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `ab_user` (`id`),
  CONSTRAINT `ab_user_role_ibfk_2` FOREIGN KEY (`role_id`) REFERENCES `ab_role` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;

-- ----------------------------
-- Records of ab_user_role
-- ----------------------------
BEGIN;
INSERT INTO `ab_user_role` VALUES (1, 1, 1);
INSERT INTO `ab_user_role` VALUES (2, 2, 1);
INSERT INTO `ab_user_role` VALUES (4, 3, 2);
COMMIT;

-- ----------------------------
-- Table structure for ab_view_menu
-- ----------------------------
DROP TABLE IF EXISTS `ab_view_menu`;
CREATE TABLE `ab_view_menu` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(250) NOT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE KEY `name` (`name`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=52 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;

-- ----------------------------
-- Records of ab_view_menu
-- ----------------------------
BEGIN;
INSERT INTO `ab_view_menu` VALUES (8, 'AuthDBView');
INSERT INTO `ab_view_menu` VALUES (17, 'Base Permissions');
INSERT INTO `ab_view_menu` VALUES (27, 'CodebaseFolderView');
INSERT INTO `ab_view_menu` VALUES (29, 'CodebaseView');
INSERT INTO `ab_view_menu` VALUES (47, 'DatasourceView');
INSERT INTO `ab_view_menu` VALUES (50, 'EnvironmentEditView');
INSERT INTO `ab_view_menu` VALUES (44, 'EnvironmentView');
INSERT INTO `ab_view_menu` VALUES (48, 'FileFolderView');
INSERT INTO `ab_view_menu` VALUES (49, 'FileView');
INSERT INTO `ab_view_menu` VALUES (33, 'ImageConfigView');
INSERT INTO `ab_view_menu` VALUES (1, 'IndexView');
INSERT INTO `ab_view_menu` VALUES (35, 'InvitationView');
INSERT INTO `ab_view_menu` VALUES (13, 'List Roles');
INSERT INTO `ab_view_menu` VALUES (10, 'List Users');
INSERT INTO `ab_view_menu` VALUES (3, 'LocaleView');
INSERT INTO `ab_view_menu` VALUES (30, 'MachineConfigView');
INSERT INTO `ab_view_menu` VALUES (22, 'MenuApi');
INSERT INTO `ab_view_menu` VALUES (46, 'NB');
INSERT INTO `ab_view_menu` VALUES (45, 'NBView');
INSERT INTO `ab_view_menu` VALUES (21, 'Permission on Views/Menus');
INSERT INTO `ab_view_menu` VALUES (16, 'PermissionModelView');
INSERT INTO `ab_view_menu` VALUES (20, 'PermissionViewModelView');
INSERT INTO `ab_view_menu` VALUES (23, 'PorosEntityView');
INSERT INTO `ab_view_menu` VALUES (24, 'PorosModelView');
INSERT INTO `ab_view_menu` VALUES (6, 'ResetMyPasswordView');
INSERT INTO `ab_view_menu` VALUES (5, 'ResetPasswordView');
INSERT INTO `ab_view_menu` VALUES (12, 'RoleModelView');
INSERT INTO `ab_view_menu` VALUES (11, 'Security');
INSERT INTO `ab_view_menu` VALUES (4, 'SecurityApi');
INSERT INTO `ab_view_menu` VALUES (37, 'ShortcutView');
INSERT INTO `ab_view_menu` VALUES (41, 'SNB用户');
INSERT INTO `ab_view_menu` VALUES (15, 'User\'s Statistics');
INSERT INTO `ab_view_menu` VALUES (9, 'UserDBModelView');
INSERT INTO `ab_view_menu` VALUES (7, 'UserInfoEditView');
INSERT INTO `ab_view_menu` VALUES (14, 'UserStatsChartView');
INSERT INTO `ab_view_menu` VALUES (39, 'UsserView');
INSERT INTO `ab_view_menu` VALUES (2, 'UtilView');
INSERT INTO `ab_view_menu` VALUES (18, 'ViewMenuModelView');
INSERT INTO `ab_view_menu` VALUES (19, 'Views/Menus');
INSERT INTO `ab_view_menu` VALUES (42, 'WorkSpaceView');
INSERT INTO `ab_view_menu` VALUES (43, '工作空间');
INSERT INTO `ab_view_menu` VALUES (38, '快捷键配置');
INSERT INTO `ab_view_menu` VALUES (31, '机器配置');
INSERT INTO `ab_view_menu` VALUES (51, '环境配置');
INSERT INTO `ab_view_menu` VALUES (40, '用户');
INSERT INTO `ab_view_menu` VALUES (25, '知识建模');
INSERT INTO `ab_view_menu` VALUES (26, '系统代码块');
INSERT INTO `ab_view_menu` VALUES (28, '系统代码块-目录');
INSERT INTO `ab_view_menu` VALUES (32, '系统配置');
INSERT INTO `ab_view_menu` VALUES (36, '邀请码配置');
INSERT INTO `ab_view_menu` VALUES (34, '镜像配置');
COMMIT;

-- ----------------------------
-- Table structure for tb_snb_dashboard_draft
-- ----------------------------
DROP TABLE IF EXISTS `tb_snb_dashboard_draft`;
CREATE TABLE `tb_snb_dashboard_draft` (
  `uid` varchar(36) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT 'UUID1 生成主键，用snb_utils 包',
  `nb_uid` varchar(36) DEFAULT NULL COMMENT 'NB_ID',
  `ws_uid` varchar(36) DEFAULT NULL,
  `layout_type` varchar(15) DEFAULT NULL COMMENT '是article 还是dashboard\n',
  `path` varchar(45) DEFAULT NULL COMMENT 'miio地址',
  `status` int(1) DEFAULT NULL COMMENT '0 草稿，1发布',
  `creat_uid` varchar(36) DEFAULT NULL COMMENT '创建人',
  `update_uid` varchar(36) DEFAULT NULL COMMENT '修改人',
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  `update_time` datetime DEFAULT NULL COMMENT '修改时间',
  `envir_uid` varchar(36) DEFAULT NULL COMMENT '执行环境UID',
  PRIMARY KEY (`uid`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='草稿';

-- ----------------------------
-- Records of tb_snb_dashboard_draft
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for tb_snb_dashboard_publish
-- ----------------------------
DROP TABLE IF EXISTS `tb_snb_dashboard_publish`;
CREATE TABLE `tb_snb_dashboard_publish` (
  `uid` varchar(36) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT 'UUID1 生成主键，用snb_utils 包',
  `dashboard_draft_uid` varchar(36) DEFAULT NULL COMMENT '草稿ID',
  `share_name` varchar(64) DEFAULT NULL COMMENT '默认nb名称_ 可更改',
  `share_uid` varchar(36) DEFAULT NULL COMMENT '分享人',
  `visibility_type` varchar(10) DEFAULT NULL,
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  `update_time` datetime DEFAULT NULL COMMENT '修改时间',
  `hash_uid` varchar(255) DEFAULT NULL,
  `url` varchar(255) DEFAULT NULL,
  `ws_uid` varchar(36) DEFAULT NULL,
  `nb_uid` varchar(36) DEFAULT NULL COMMENT 'NB_ID',
  `envir_uid` varchar(36) DEFAULT NULL COMMENT '执行环境UID',
  PRIMARY KEY (`uid`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='发布';

-- ----------------------------
-- Records of tb_snb_dashboard_publish
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for tb_snb_status
-- ----------------------------
DROP TABLE IF EXISTS `tb_snb_status`;
CREATE TABLE `tb_snb_status` (
  `id` int(11) NOT NULL,
  `name` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;

-- ----------------------------
-- Records of tb_snb_status
-- ----------------------------
BEGIN;
INSERT INTO `tb_snb_status` VALUES (0, '无效');
INSERT INTO `tb_snb_status` VALUES (1, '有效');
COMMIT;

-- ----------------------------
-- Table structure for tb_snb_sys_codebase
-- ----------------------------
DROP TABLE IF EXISTS `tb_snb_sys_codebase`;
CREATE TABLE `tb_snb_sys_codebase` (
  `uid` varchar(36) COLLATE utf8_bin NOT NULL COMMENT '代码块的UID',
  `name` varchar(64) COLLATE utf8_bin DEFAULT NULL COMMENT '名称',
  `language` varchar(16) COLLATE utf8_bin DEFAULT NULL COMMENT '语言：python、sql',
  `folder_uid` varchar(36) COLLATE utf8_bin DEFAULT NULL,
  `code` varchar(3072) COLLATE utf8_bin DEFAULT NULL COMMENT '代码',
  `tag` varchar(32) COLLATE utf8_bin DEFAULT NULL COMMENT '标签',
  `create_time` datetime DEFAULT NULL,
  `update_time` datetime DEFAULT NULL,
  `status` int(11) DEFAULT NULL COMMENT '1 有效 0 无效',
  PRIMARY KEY (`uid`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin ROW_FORMAT=DYNAMIC COMMENT='代码库';

-- ----------------------------
-- Records of tb_snb_sys_codebase
-- ----------------------------
BEGIN;
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b0f1b6-b656', '计算频率来转置表', 'python3', '0242ac110007-11ed3a12-93b0ef18-b656', 'freqs = my_df.pivot_table(\n    rows=[\"make\"],\n    cols=[\"fuel_type\", \"aspiration\"],\n    margins=True     # add subtotals on rows and cols\n)', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b0f95e-b656', '数据导入', 'python3', '0242ac110007-11ed3a12-93b0f77e-b656', 'import pandas as pd\nimport numpy as np\nuniform_data = np.random.rand(10,12)\ndata = pd.DataFrame( ( \'x\': np.array(1, 101), \n\'y\': np.random.normal( 0,4,100 ) ) )\n\n#内部数据集\ntitanic = sns.load_dataset( \"titanic\" ) \niris = sns.load_dataset( \"iris\" )', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b0fdd2-b656', '使用sklearn', 'python3', '0242ac110007-11ed3a12-93b0fc42-b656', 'import sklearn\nsklearn.linear_model.LinearRegression()\n\n# http://scikit-learn.org/stable/modules/linear_model.html', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b101d8-b656', '用一个值填补多列的缺失值', 'python3', '0242ac110007-11ed3a12-93b10048-b656', 'my_df[[\'col_0\', \'col_1\']] = my_df[[\'col_0\', \'col_1\']].fillna(value)', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b105c0-b656', '用拆堆栈进行变化(long format -> wide format)', 'python3', '0242ac110007-11ed3a12-93b1043a-b656', 'pivoted = base.unstack(level=1)', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b10836-b656', '水平连接数据', 'python3', '0242ac110007-11ed3a12-93b0ef18-b656', 'import pandas as pd\ntwo_dfs_hconcat = pd.concat([my_df, my_df2], axis=1)', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b10cbe-b656', '将dataframe的index重置成标准值', 'python3', '0242ac110007-11ed3a12-93b0ef18-b656', 'my_df_no_index = my_df.reset_index()\n# my_df_no_index.index is now [0, 1, 2, ...]', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b112a4-b656', '递归特征消除法', 'python3', '0242ac110007-11ed3a12-93b110e2-b656', 'import numpy as np\nfrom sklearn import feature_selection\nfrom sklearn.linear_model import LogisticRegression\n\nmatrix = np.array(X)\ntarget = np.array(target)\ntemp = feature_selection.RFE(estimator=LogisticRegression(), n_features_to_select=n_features).fit(matrix, target)\nscores = temp.ranking_.tolist()\nindx = temp.support_.tolist()\nresult = temp.transform(matrix).tolist()\nreturn scores, indx, result\n\n# X: array-like\n# target: array-like\n# n-features: int\n# http://scikit-learn.org/stable/modules/generated/sklearn.feature_selection.RFE.html', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b11538-b656', '相关系数选择法', 'python3', '0242ac110007-11ed3a12-93b110e2-b656', 'import numpy as np\nfrom sklearn import feature_selection\nfrom sklearn.feature_selection import chi2\n\nmatrix = np.array(X)\ntarget = np.array(target)\ntemp = feature_selection.SelectKBest(lambda X, Y: np.array(list(map(lambda x: abs(pearsonr(x, Y)[0]), X.T))), k=k).fit(matrix, target)\nscores = temp.scores_.tolist()\nindx = temp.get_support().tolist()\nresult = temp.transform(matrix).tolist()\nreturn scores, indx, result\n\n# X: array-like\n# target: array-like\n# k: int\n# http://scikit-learn.org/stable/modules/generated/sklearn.feature_selection.SelectKBest.html', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b11984-b656', '皮尔森相关系数', 'python3', '0242ac110007-11ed3a12-93b11808-b656', 'import numpy as np \n\nmatrix = np.transpose(np.array(X))\nnp.corrcoef(matrix[0], matrix[1])[0, 1]\n\n# X: array-like\n# https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.corrcoef.html\n\n', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b11d4e-b656', '去除所有重复数据', 'python3', '0242ac110007-11ed3a12-93b11bd2-b656', 'import pandas as pd\n# my_df 是一个pandas dataframe\nunique_records = my_df.drop_duplicates()', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b11fe2-b656', '以元组(tuple)形式按行写入数据', 'python3', '0242ac110007-11ed3a12-93b0ef18-b656', 'import pandas as pd\npy_recipe_output = pd.read_csv(\"data.csv\")\nwriter = py_recipe_output.get_writer()\n\n# t is of the form :\n#   (value0, value1, ...)\n\nfor t in data_to_write:\n    writer.write_tuple(t)', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b12258-b656', '数据重构', 'python3', '0242ac110007-11ed3a12-93b0ef18-b656', '#Pivot\ndf3 = df2.pivot( index = \'Date\', \ncolumns = \'Type\', values = \'Value\') #行变列\n\n#Pivot Table\ndf4 = pd.pivot_table( df2,\nvalues=\'Value\',\nindex = \'Date\', \ncolumns=\'Type\'] #行变列\n\n#Stack/Unstack\nstacked = df5.stack( ) \nstacked.unstacked( )\n\n#Melt\npd.melt(df2, id_vars=[\"Date\"], \nvalue_vars=[\"Type\",\"Value\"], \nvalue_name=\"Observations\") \n#将列变行\n', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b12514-b656', '移动平均数', 'python3', '0242ac110007-11ed3a12-93b11808-b656', 'import numpy as np\n\nret = np.cumsum(np.array(X), dtype=float)\nret[w:] = ret[w:] - ret[:-w]\nresult = ret[w - 1:] / w\n\n# X: array-like\n# window: int\n', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b12780-b656', '用数据的位置获取数据', 'python3', '0242ac110007-11ed3a12-93b0ef18-b656', 'my_record = my_df.iloc[1]  # !! get the second records, positions start at 0', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b129f6-b656', '列的分位数', 'python3', '0242ac110007-11ed3a12-93b11808-b656', 'import pandas as pd\n# set columns type\nmy_df[\'col\'] = my_df[\'col\'].astype(np.float64)\n\n# computations for 4 quantiles : quartiles\nbins_col = pd.qcut(my_df[\'col\'], 4)\nbins_col_label = pd.qcut(my_df[\'col\'], 4).labels', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b12c76-b656', '多重聚合(组数据)', 'python3', '0242ac110007-11ed3a12-93b11808-b656', '# columns settings\ngrouped_on = \'col_0\'  # [\'col_0\', \'col_2\'] for multiple columns\naggregated_column = \'col_1\'\n\n### Choice of aggregate functions\n## On non-NA values in the group\n## - numeric choice :: mean, median, sum, std, var, min, max, prod\n## - group choice :: first, last, count\n# list of functions to compute\nagg_funcs = [\'mean\', \'max\']\n\n\n# compute aggregate values\naggregated_values = my_df.groupby(grouped_on)[aggregated_columns].agg(agg_funcs)\n\n# get the aggregate of group\naggregated_values.ix[group]', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b12eec-b656', '从列新建虚数据', 'python3', '0242ac110007-11ed3a12-93b0ef18-b656', 'import pandas as pd\ndummified_cols = pd.get_dummies(my_df[\'col\']\n    # dummy_na=True # to include NaN values\n    )', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b134a0-b656', 'PCA主成分分析算法', 'python3', '0242ac110007-11ed3a12-93b13144-b656', 'import numpy as np\nfrom sklearn.decomposition import PCA\n\nmatrix = np.array(X)\npca = PCA(n_components=\'mle\', svd_solver=\'auto\').fit(matrix)\nresult = pca.transform(matrix)\nlabel = result.tolist()\nreturn label, pca.components_.tolist(), pca.explained_variance_.tolist(), pca.explained_variance_ratio_.tolist(), pca.mean_.tolist(), pca.noise_variance_\n\n', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b170be-b656', '合并有相同名称的列的两个dataframe', 'python3', '0242ac110007-11ed3a12-93b0ef18-b656', 'import pandas as pd\n# my_df 是一个pandas dataframe\nmerged = my_df.merge(my_df2,\non=\'col\', # [\'col_0\', \'col_1\'] for many\nhow=\"inner\",\n# suffixes=(\"_from_my_df\", \"_from_my_df2\"))', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b18d2e-b656', '合并两个dataframe没有相同名称的列', 'python3', '0242ac110007-11ed3a12-93b0ef18-b656', '# 每次只合并两个dataframe\n# 合并方式 : \'left\', \'right\', \'outer\', \'inner\'\nimport pandas as pd\n# my_df 是一个pandas dataframe\nmerged = my_df.merge(my_df2,\nleft_on=[\'col_0\', \'col_1\'],\nright_on=[\'col_2\', \'col_3\'],\n# suffixes=(\"_from_my_df\", \"_from_my_df2\")\nhow=\"inner\")', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b195da-b656', '使用复杂的方程设值', 'python3', '0242ac110007-11ed3a12-93b1912a-b656', 'import numpy as np\ndef complex_formula(col0_value, col1_value):\n    return \"%s (%s)\" % (col0_value, col1_value)\n\nmy_df[\'new_col\'] = np.vectorize(complex_formula)(my_df[\'col_0\'], my_df[\'col_1\'])', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b19a3a-b656', 'array处理', 'python3', '0242ac110007-11ed3a12-93b198aa-b656', 'import numpy as np\n\n#Transposing Array\nI = np.transpose(b) #转置矩阵\ni.T #转置矩阵\n\n#Changing Array Shape\nb.ravel() #降为一维数组\ng.reshape(3,-2) #重组\n\n#Adding/Removing Elements\nh.resize((2,6)) #返回shape(2,6)\nnp.append(h,g) #添加\nnp.insert(a,1,5) #插入\nnp.delete(a,[1]) #删除\n\n#Combining Arrays\nnp.concatenate((a,d), axis=0) #连结\nnp.vstack((a,b)) #垂直堆叠\nnp.r_[e,f] #垂直堆叠\nnp.hstack((e,f)) #水平堆叠\nnp.column_stack((a,d)) #创建水平堆叠\nnp.c_[a,d] ##创建水平堆叠\n\n#splitting arrays\nnp.hsplit(a,3) #水平分离\nnp.vsplit(c,2) #垂直分离\n', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b19e0e-b656', '输出', 'python3', '0242ac110007-11ed3a12-93b19c92-b656', '#Notebook: \nfrom bokeh.io \nimport output_notebook, show\noutput_notebook( )\n\n#HTML:\n\n#Standalone HTML \nfrom bokeh.embed \nimport file_html; \nfrom bokeh.resources \nimport CDN; \nhtml=file_html(p,CDN,\"my_plot\");\nfrom bokeh.io \nimport output_file,show; \noutput_file(\'my_bar_chart.html\',\nmode=\'cdn\')\n\n#Components:\nfrom bokeh.embed \nimport components; \nscript, div=components(p)\n\n#PNG: \nfrom bokeh.io import export_png;\nexport_png(p,filename=\"plot.png\")\n\n#SVG:\nfrom bokeh.io import export_svgs;\np.output_backend=\"svg\";\nexport_svgs(p,filename=\"plot.svg\")', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b1a070-b656', '分组数据', 'python3', '0242ac110007-11ed3a12-93b0ef18-b656', '#aggregation\ndf2.groupby(\nby=[\'Data\', \'Type\']).mean()\ndf4.groupby(level=0).sum()\ndf4.groupby(level=0).agg\n({\'a\':lama x:sum(x)/len(x), \n\'b\':np.sum})\n\n#Transformation\ncustomSum=lamda x:(x+x%2)\ndf4.groupby\n(level=0).transform(customSum)', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b1a444-b656', '随机梯度下降(SGD)', 'python3', '0242ac110007-11ed3a12-93b1a2d2-b656', '# http://scikit-learn.org/stable/modules/generated/sklearn.linear_model.SGDClassifier.html#sklearn.linear_model.SGDClassifier\nfrom sklearn.linear_model import SGDClassifier\n\nclf = SGDClassifier(loss=\"hinge\", penalty=\"l2\")\nclf.fit(X, y)\n\n# 数组 X shape:[n_samples, n_features]\n# 数组 y shape:[n_samples]', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b1a84a-b656', '用栈变化(wide format -> long format)', 'python3', '0242ac110007-11ed3a12-93b1043a-b656', 'stacked = pivoted.stack(dropna=True)', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b1ae4e-b656', 'swarmplot', 'python3', '0242ac110007-11ed3a12-93b1ab74-b656', 'import seaborn as sns\n%matplotlib inline\nsns.swarmplot(x=\'species\',y=\'petal_length\',data=my_data) # 以iris数据集为例', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b1b0e2-b656', '方差选择', 'python3', '0242ac110007-11ed3a12-93b110e2-b656', 'import numpy as np\nfrom sklearn import feature_selection\n\nmatrix = np.array(X)\ntemp = feature_selection.VarianceThreshold(threshold=t).fit(matrix)\nscores = [np.var(el) for el in matrix.T]\nindx = temp.get_support().tolist()\nresult = temp.transform(matrix).tolist()\nreturn scores, indx, result\n\n# X: array-like\n# t: float\n# http://scikit-learn.org/stable/modules/generated/sklearn.feature_selection.VarianceThreshold.html', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b1b36c-b656', '使用melt降维(wide format -> long format)', 'python3', '0242ac110007-11ed3a12-93b1043a-b656', '# melt是一种降维的方法\nimport pandas as pd\nrows = pd.melt(pivoted, id_vars=[\"type\"])', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b1b5ec-b656', '使用目标值的位置定位替换值', 'python3', '0242ac110007-11ed3a12-93b0ef18-b656', 'import pandas as pd\n# my_df 是一个pandas dataframe\nmy_df[]\'col\'].iloc[0] = new_value  # replacement for first record', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b1b844-b656', '以列值排序', 'python3', '0242ac110007-11ed3a12-93b11808-b656', 'import pandas as pd\n# my_df 是pandas dataframe\nmy_df[\'col_0\'].value_counts().sort_index()', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b1bab0-b656', '创建array', 'python3', '0242ac110007-11ed3a12-93b198aa-b656', 'import numpy as np\na = np.array([1,2,3])   #创建数组\nb = np.array([(1.5,2,3), (4,5,6)], \ndtype=float)\nc = np.array([(1.5,2,3), (4,5,6)], \n[(3,2,1), (4,5,6) ] ], dtype=float)\n\nnp.zeros((3,4))  #创建0数组\nnp.ones((2,3,4), dtype=np.int16)  #创建1数组\nd = np.arrange(10,25,5)  #创建相同步数数组\nnp.linspace(0,2,9)  #创建等差数组\n\ne = np.full((2,2), 7) #创建常数数组\nf = np.eye(2) #创建2x2矩阵\nnp.random.random((2,2)) #创建随机数组\nnp.empty((3,2)) #创建空数组\n', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b1bd30-b656', '图像绘制', 'python3', '0242ac110007-11ed3a12-93b0f77e-b656', '#axis grids\ng = sns.FacetGrid(titanic, \ncol = \"survived\", row = \"sex\" ) \n#subplot grid\ng = g.map( pot.hist, \"age\")\n\nsns.factorplot( x = \"pclass\",\ny = \"survived\", hue = \"sex\", \ndata = titanic) # categorical plot\nsns. lmplot( x = \"sepal_width\",\n y = \"sepal_length\", hue = \"species\", \ndata = iris) \n#plot data and regression model\n\nh = sns.PairGrid( iris ) \n#subplot grid for plotting pairwise relationships\nh = h.map( pot.scatter) \nsns.pairplot( iris ) \n#plot pairwise bivariate distributions\ni = sns.JointGrid( x = \"x\",\n y = \"y\", data= data )\n #grid for bivariate plot with marginal\ni = i.plot( sns.regplot, sns.distplot )\nsns.jointplot( \"sepal_length\", \n\"sepal_width\", data = iris, kind = \'kde\')\n#plot bivariate distribution\n\n\n#Categorical Plots\n\n#Scatterplot\nsns.stripplot( x = \"species\", \ny = \"petal_length\", data = iris)\nsns.swarmplot( x = \"species\", \ny = \"petal_length\", data = iris)\n\n#bar chart\nsns.barplot( x = \"sex\", y = \"survived\",\n hue = \"class\", data = titanic)\n\n#count plot\nsns.countplot( x = \"deck\", \ndata = titanic, palette = \"Greens_d\")\n\n#Point Plot\nsns.pointplot( x = \"class\", y = \"survived\",\nhue = \"sex\", data = titanic, \npalette ={ \"male\": \"g\", \"female\": \"m\"}, \nmarkers = [ \"^\",\"o\"], linestyles = [\"-\",\"--\"])\n\n#Boxplot\nsns.boxplot( x = \"alive\", y = \"age\",\nhue = \"adult_male\", data = titanic)\nsns.boxplot( data = iris, orient = \"h\")\n\n#Violinplot\nsns.violinplot( x = \"age\", y = \"sex\",\n hue = \"survived\", data = titanic ) \n\n\n#regression plots\nsns.regplot(x=\"sepal_width\", \ny =\"sepal_length\", data=iris, ax=ax)\n\n#distribution plots\nplot = sns.displot(data.y, \nkde=False, color=\"b\")\n\n#Matrix plots\nsns.heatmap(uniform_data, \nvmin=0, vmax=1)\n', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b1c1a4-b656', '数据录入', 'python3', '0242ac110007-11ed3a12-93b1c028-b656', 'import numpy as np\n#1D data\nx = np.linspace(0, 10, 100)\ny = np.cos(x)\nz = np.sin(x)\n\n#2D data or images\ndata = 2* np.random.random((10,10))\ndata2 = 3 * np.random.random((10,10))\nY, X = np.mgrid[-3:3:100j, -3:3:100j]\nU = -1-X**2+Y\nV = 1+X-Y**2\nfrom Matplotlib.cbook \nimport get_sample_data\nimg = np.load(get_sample_data\n(\'axes_grid/bivariate_normal.npy\'))', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b1c406-b656', '数据导入', 'python3', '0242ac110007-11ed3a12-93b19c92-b656', 'import numpy as np\nimport pandas as pd\ndf=pd.DataFrame(\nnp.array([[ 33.9, 4, 65, \'US\'], \n[32.4,4, 66, \'Asia\'], \n[21.4, 4,109, \'Europe\'] ] ), \ncolumns = [ \'mpg\', \'cyl\', \'hp\', \'origin\'],\nindex= [ \'Toyota\', \'Fiat\', \'Volvo\'] )\n\nfrom bokeh.models\nimport ColumnDataSource \ncds_df=ColumDataSource(df)', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b1c654-b656', '用户定义方程(组数据)', 'python3', '0242ac110007-11ed3a12-93b11808-b656', '# columns settings\ngrouped_on = [\'col_0\']\naggregated_columns = [\'col_1\']\n\ndef my_func(my_group_array):\n    return my_group_array.min() * my_group_array.count()\n\n## list of functions to compute\nagg_funcs = [my_func] # could be many\n\n# compute aggregate values\naggregated_values = my_df.groupby(grouped_on)[aggregated_columns].agg(agg_funcs)\n', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b1c8ac-b656', '分簇', 'python3', '0242ac110007-11ed3a12-93b0ef18-b656', 'import pandas as pd\n# Set columns type\nmy_df[\'col\'] = my_df[\'col\'].astype(np.float64)\n\n# Computations\nbins = [0, 100, 1000, 10000, 100000] # 5 binned, labeled 0,1,2,3,4\nbins_col = pd.cut(my_df[\'col\'], bins)\nbins_col_label = pd.cut(my_df[\'col\'], bins).labels', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b1cafa-b656', '获取元组(tuple)的迭代器', 'python3', '0242ac110007-11ed3a12-93b0ef18-b656', 'import pandas as pd\nmy_dataset = pd.read_csv(\"path_to_dataset\")\n\ni = 0\nfor my_row_as_tuple in my_dataset.iter_tuples():\n    if i > 10:\n        break\n    i += 1\n    print (my_row_as_tuple)', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b1cd70-b656', '获取文档', 'python3', '0242ac110007-11ed3a12-93b0ef18-b656', '# Everywhere\nprint(my_df.__doc__)\nprint(my_df.sort.__doc__)\n\n# When using notebook : append a \'?\' to get help\nmy_df?\nmy_df.sort?', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b1d1ee-b656', '用一个值填补一列的缺失值', 'python3', '0242ac110007-11ed3a12-93b10048-b656', 'my_df[\'col\'] = my_df[\'col\'].fillna(value)', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b1f660-b656', '归一化', 'python3', '0242ac110007-11ed3a12-93b11bd2-b656', 'import numpy as np\nfrom sklearn import preprocessing\n\nraw_result = preprocessing.Normalizer().fit_transform(np.array(X))\nresult = raw_result.tolist()\n\n# X: array-like\n# http://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.Normalizer.html', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b1fade-b656', '标准差', 'python3', '0242ac110007-11ed3a12-93b11808-b656', 'import numpy as np\nnp.std(np.array(X))\n\n# X: array-like\n# https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.std.html', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b1fdcc-b656', '复制数据', 'python3', '0242ac110007-11ed3a12-93b0ef18-b656', 's3.unique() \n#返回唯一值\ndf2.duplicated(\'Tyepe\') \n#检查重复值\ndf2.drop_duplicates(\n\'Type\', keep=last\'\') \n#丢弃重复值\ndf.index.duplicated() \n#检查索引重复', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b20056-b656', '排序array', 'python3', '0242ac110007-11ed3a12-93b198aa-b656', '#对数组进行排序\na.sort()\nc.sort(axis=0)', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b202b8-b656', '在聚合的dataframe上使用用户定义方程', 'python3', '0242ac110007-11ed3a12-93b11808-b656', '# top n in aggregate dataframe\ndef top_n(group_df, col, n=2):\n    bests = group_df[col].value_counts()[:n]\n    return bests\n\n# columns settings\ngrouped_on = \'col_0\'\naggregated_column = \'col\'\n\ngrouped = my_df.groupby(grouped_on)\ngroups_top_n = grouped.apply(top_n, aggregated_column, n=3)', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b2052e-b656', '标准聚合(使用groupby)', 'python3', '0242ac110007-11ed3a12-93b1912a-b656', '# columns settings\ngrouped_on = \'col_1\'\naggregated_column = \'col_0\'\n\n### Choice of aggregate functions\n## On non-NA values in the group\n## - numeric choice : mean, median, sum, std, var, min, max, prod\n## - group choice : first, last, count\nmy_df[\'aggregate_values_on_col\'] = my_df.groupby(grouped_on)[aggregated_column].transform(lambda v: v.mean())\n', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b207c2-b656', 'pairplot', 'python3', '0242ac110007-11ed3a12-93b1ab74-b656', 'import seaborn as sns\nsns.pairplot(iris,hue=\'Species\')', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b20a24-b656', 'countplot', 'python3', '0242ac110007-11ed3a12-93b1ab74-b656', 'import seaborn as sns;titanic= sns.load_dataset(\'titanic\')\nsns.countplot(y=\"deck\", hue=\"class\", data=titanic, palette=\"Greens_d\") # 以titanic数据集为例', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b20c9a-b656', '高度专门化的线性回归函数(scipy.stats)', 'python3', '0242ac110007-11ed3a12-93b0fc42-b656', 'import scipy\nfrom scipy import stats\n\nstats.linregress(x, y=none)\n\n# x, y : array_like\n# https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.linregress.html\n', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b20f06-b656', '所有列(列的数据类型为数值型)', 'python3', '0242ac110007-11ed3a12-93b11808-b656', 'my_df.describe()', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b21140-b656', '自定义', 'python3', '0242ac110007-11ed3a12-93b0f77e-b656', '#Axisgrid Objects\ng.despine( left = True) \n#remove left spine\ng.set_ylabels( \"Survived\") \n#set the labels of the y-axis\ng.set_xticklabels( rotation = 45) \n#set the tick labels for x\ng.set_axis_labels( \"Survived\", \"Sex\")\n #set the axis labels\nh.set( xlim = (0,5), ylim = (0,5), \nxticks = [0,2.5,5], yticks =[0,2.5,5] )\n#set the limit and ticks of the x- and y-axis\n\n#Plot\nplt.title( \"A title\" ) \n#add plot title\nplt.ylabel( \"Survived\" ) \n#adjust the label of the y-axis\nplt.xlabel( \"Sex\" ) \n#adjust the label of the x-axis\nplt.ylim(0,100)\n #adjust the limits of the y-axis\nplt.xlim(0,10) \n#adjust the limits of the x-axis\npot.setp(ax, yticks =[0,5]) \n#adjust a plot property\nplt.tight_layout() \n#adjust subplot params\n', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b213d4-b656', '使用Statsmodels的模型', 'python3', '0242ac110007-11ed3a12-93b0fc42-b656', 'import statsmodels.api as sm\nresults = sm.OLS(y, X).fit()\n\n# y: matrix\n# X: constant\n# http://www.statsmodels.org/dev/index.html', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b21636-b656', '去除在指定列中带有缺失值的数据条目', 'python3', '0242ac110007-11ed3a12-93b10048-b656', 'cols = [\'col_0\', \'col_1\']\nrecords_without_nas_in_cols = my_df.dropna(subset=cols)', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b218a2-b656', '重命名所有列', 'python3', '0242ac110007-11ed3a12-93b0ef18-b656', 'my_df.columns = [\'new_col_0\', \'new_col_1\']  # needs the right number of columns', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b21b0e-b656', '设置聚合方程进行交叉制表', 'python3', '0242ac110007-11ed3a12-93b0ef18-b656', '# 交叉制表是统计学中一个将分类数据聚合成列联表的操作\nimport pandas as pd\n# my_df 是一个pandas dataframe\nstats =  pd.crosstab(\n    rows=my_df[\"make\"],\n    cols=[my_df[\"fuel_type\"], my_df[\"aspiration\"]],\n    values=my_df[\"horsepower\"],\n    aggfunc=\'max\',   # aggregation function\n    margins=True     # add subtotals on rows and cols\n)', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b21f6e-b656', '以频率降序排序', 'python3', '0242ac110007-11ed3a12-93b11808-b656', 'import pandas as pd\n# my_df 是pandas dataframe\nmy_df[\'col_0\'].value_counts()', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b2232e-b656', '索引', 'python3', '0242ac110007-11ed3a12-93b198aa-b656', 'import numpy as np\n#subsetting\na[2] #选取数组第三个元素\nb[1,2] #选取2行3列元素\n\n#slicing\na[0:2] #选1到3元素\nb[0:2,1] #选1到2行的2列元素\nb[:1] #选所有1行的元素\nc[1,...] #c[1,:,:]\na[ : :-1]  #反转数组\n\n#Boolean Indexing\na[a<2] #选取数组中元素<2的\n\n#Fancy Indexing\nb[[1,0,1,0], [0,1,2,0]]\n#选取[1,0],[0,1],[1,2],[0,0]\nb[[1,0,1,0][:, [0,1,2,0]]] \n#选取矩阵的一部分\n\n', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b225d6-b656', '高级索引', 'python3', '0242ac110007-11ed3a12-93b0ef18-b656', '#basic\ndf3.loc[:, (df3>1).any()] \n#选列 其中任意元素>1\ndf3.loc[:, (df3>1).all()] \n#选列 其中所有>1\ndf3.loc[:, df3.isnull().any()] \n#选列 其中含空\ndf3.loc[:,df3.notnull().all()] \n#选列 其中不含空\n\ndf[(df.Country.isin(df2.Type))] \n#寻找相同元素\ndf3.filter(items=[\"a\",\"b\"]) \n#根据值筛选\ndf.select(lamda x: not x%5) \n#选特定元素\n\ns.where(s>0) \n#数据分子集\n\ndf6.query(\'second >first\') \n#query 数据结构\n\n\n#selecting\ndf.set_index(\'Country\') \n#设置索引\ndf4 = df.reset_index() \n#重置索引\ndf =df.rename(index = str, \ncolumns={\"Country\":\"cntry\", \n\"Capital\":\"cptl\",\"Population\":\"ppltn\"}) \n#重命名数据结构\n\n#Reindexing\ns2 = s.reindex([\'a\', \'c\', \'d\', \'e\', \'b\'])\n#Forward Filling\ndf.reindex(range(4), \nmethod=\'ffill\')\n#Backward Filling\ns3 = s.reindex(range(5), \nmethod=\'bfill\')\n\n#MultiIndexing\narrays = [np.array([1,2,3]), \nnp.array([5,4,3])]\ndf5 = pd.DataFrame(\nnp.random.rand(3,2), index = arrays)\ntuples = list(zip( *arrays))\nindex = pd.MultiIndex.from_tuples(\ntuples, names=[\'first\', \'second\'])\ndf6 = pd.DataFrame(\nnp.random.rand(3,2), index = index)\ndf2.set_index([\"Data\",\"Type\"])', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b228a6-b656', '使用某种法则替换列中的值', 'python3', '0242ac110007-11ed3a12-93b0ef18-b656', 'import numpy as np\nrules = {\n    value: value1,\n    value2: value3,\n    \'Invalid\': np.nan  # replace by an true invalid value\n}\n\nmy_df[\'col\'] = my_df[\'col\'].map(rules)', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b22b58-b656', '遍历数据字典', 'python3', '0242ac110007-11ed3a12-93b0ef18-b656', 'import pandas as pd\nmy_dataset = pd.read_csv(\"path_to_dataset\")\n\ni = 0\nfor my_row_as_dict in my_dataset.iter_rows():\n    if i > 10:\n        break\n    i += 1\n    print my_row_as_dict', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b22dba-b656', '垂直连接数据', 'python3', '0242ac110007-11ed3a12-93b0ef18-b656', 'two_dfs_vconcat = my_df1.append(my_df2)', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b22ff4-b656', 'violinplot', 'python3', '0242ac110007-11ed3a12-93b1ab74-b656', 'import seaborn as sns;iris = sns.load_dataset(\'iris\')\nsns.violinplot(x=\'species\',y=\'sepal_length\',data=iris) # 以iris数据集为例', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b23346-b656', 'pointplot', 'python3', '0242ac110007-11ed3a12-93b1ab74-b656', 'import seaborn as sns; iris = sns.load_dataset(\'iris\')\nsns.pointplot(x=\'species\',y=\'petal_width\',data=iris) # 以iris数据集为例', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b235bc-b656', '哑编码', 'python3', '0242ac110007-11ed3a12-93b13144-b656', 'import numpy as np\nfrom sklearn import preprocessing\n\nraw_result = preprocessing.OneHotEncoder().fit_transform(np.array(X))\nresult = raw_result.tolist()\n\n# X: array-like\n# http://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.OneHotEncoder.html', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b2383c-b656', '一般的最小二乘多项式拟合(numpy)', 'python3', '0242ac110007-11ed3a12-93b0fc42-b656', 'import numpy as np\nnp.polyfit(x, y, deg, rcond=None, full=False, w=None, cov=False)\n# x : array_like, shape (M,)\n# y : array_like, shape (M,) or (M, K)\n# deg : int\n# https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.polyfit.html', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b23a9e-b656', '计算频率进行交叉制表', 'python3', '0242ac110007-11ed3a12-93b0ef18-b656', '# 交叉制表是统计学中一个将分类数据聚合成列联表的操作\nimport pandas as pd\n# my_df 是一个pandas dataframe\nfreqs = pd.crosstab(\n    rows=my_df[\"make\"],\n    cols=[my_df[\"fuel_type\"], my_df[\"aspiration\"]]\n)', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b23d64-b656', '基本运算', 'python3', '0242ac110007-11ed3a12-93b198aa-b656', 'import numpy as np\n\n#arithmetic operation算术运算\ng = a - b\nnp.subtract(a,b) #减法\nb+a\nnp.add(b,a) #加法\na / b\nnp.divide(a,b) #除法\na * b\nnp.multiply(a,b) #乘法\nnp.exp(b) #指数\nnp.sqrt(b) #开方\nnp.sin(a) #sin函数\nnp.cos(b) #cos函数\nnp.log(a) #log函数\ne.dot(f) #内积\n\n#Comparison比较\na == b #元素\na < 2 #元素\nnp.array_equal(a,b) #数组 \n\n#Aggregate Functions 函数\na.sum() #求和\nb.min() #最小值\nb.max(axis=0) #最大值数组列\nb.cumsum(axis=1) #元素累加和\na.mean() #平均值\nb.median() #中位数\na.corrcoef() #相关系数\nnp.std(b) #标准差\n\n\n', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b23fe4-b656', '迭代', 'python3', '0242ac110007-11ed3a12-93b0ef18-b656', 'df.iteritems( ) #列索引 \ndf.iterrows( ) #行索引\n', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b24228-b656', '结合数据', 'python3', '0242ac110007-11ed3a12-93b0ef18-b656', '#Merge\npd.merge(data1, data2, \nhow=\'left\', on=\'X1\')\npd.merge(data1, data2,\nhow=\'right\', on=\'X1\')\npd.merge(data1, data2, \nhow=\'inner\', on=\'X1\')\npd.merge(data1, data2, \nhow=\'outer\', on=\'X1\')\n\n#join\ndata1.join(data2, how=\'right\')\n\n#concatenate\n#vertical\ns.append(s2)\n#horizontal/vertical\npd.concat([s,s2], axis=1,\n keys=[\'One\',\'Two\'])\npd.concat([data1, data2], \naxis=1, join=\'inner\')', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b24688-b656', '检查array', 'python3', '0242ac110007-11ed3a12-93b198aa-b656', 'a.shape #数组维度\nlen(a) #数组长度\nb.ndim #数组维度数量\ne.size #数组元素数量\nb.dtype #元素数据类型\nb.dtype.name #数据类型名\nb.astype(int) #改变数组类型\n\n#asking for help更多信息\nnp.info(np.ndarray.dtype)', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b24a5c-b656', '一些列的单一属性(如最大值， 列的类型为数值型)', 'python3', '0242ac110007-11ed3a12-93b11808-b656', 'my_df[\"col\"].max() # [[\"col_0\", \"col_1\"]] 多字段\n', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b24d22-b656', '用index获取数据', 'python3', '0242ac110007-11ed3a12-93b0ef18-b656', 'my_record = my_df.loc[label] # !! If the label in the index defines a unique record', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b250f6-b656', '所有列(分隔)', 'python3', '0242ac110007-11ed3a12-93b24f7a-b656', 'my_df.plot(kind=\'line\', subplots=True, figsize=(8,8))\n', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b25330-b656', 'boxplot', 'python3', '0242ac110007-11ed3a12-93b1ab74-b656', 'import seaborn as sns\nsns.boxplot(x=\'species\',y=\'Petal.Length\',data=iris) # 以iris数据集为例', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b2559c-b656', 'stripplot', 'python3', '0242ac110007-11ed3a12-93b1ab74-b656', 'import seaborn as sns; iris = sns.load_dataset(\'iris\')\nsns.stripplot(x=\'species\',y=\'sepal_length\',data=iris)', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b25b14-b656', '互信息选择法', 'python3', '0242ac110007-11ed3a12-93b110e2-b656', 'from minepy import MINE\nimport numpy as np\nfrom sklearn import feature_selection\n\nmatrix = np.array(X)\ntarget = np.array(target)\ndef mic(x, y):\n    m = MINE()\n    m.compute_score(x, y)\n    return (m.mic(), 0.5)\ntemp = feature_selection.SelectKBest(lambda X, Y: np.array(list(map(lambda x: mic(x, Y), X.T))).T[0], k=k).fit(matrix, target)\nscores = temp.scores_.tolist()\nindx = temp.get_support().tolist()\nresult = temp.transform(matrix).tolist()\nreturn scores, indx, result\n\n# X: array-like\n# target: array-like\n# k: int\n# http://scikit-learn.org/stable/modules/generated/sklearn.feature_selection.SelectKBest.html', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b25e98-b656', '使用目标值的label定位替换值', 'python3', '0242ac110007-11ed3a12-93b0ef18-b656', 'import pandas as pd\n# my_df 是一个pandas dataframe\nmy_df[\'col\'].loc[my_label] = new_value', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b26136-b656', '使用自定义方程设值', 'python3', '0242ac110007-11ed3a12-93b1912a-b656', 'def to_log(v):\n    try:\n        return log(v)\n    except:\n        return np.nan\nmy_df[\'new_col\'] = my_df[\'col_0\'].map(to_log)', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b263ac-b656', '显示与保存', 'python3', '0242ac110007-11ed3a12-93b1c028-b656', '#save plot\nplt.savefig(\'foo.png\')\nplt.savefig(\'foo.png\', transparent=True)\n\n#show plot\nplt.show()\n\n#close &clear\nplt.cla() #clear an axis\nplt.clf() #clear the entire figure\nplt.close() #close a window\n', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b26604-b656', '图像设置', 'python3', '0242ac110007-11ed3a12-93b1c028-b656', 'import matplotli.pyplot as plt\n\n#figure\nfig = plt.figure( )\nfig2 = plt.figure( figsize = \nplt.figaspect(2,0) )\n\n#axes\nfig.add_axes( )\nax1 = fig.add_subplot( 221 ) \n#row-col-num\nax3 = fig.add_subplot( 212 )\nfig3, axes = plt.subplots(\nnrows=2, ncols=2)\nfig4, axes2 = plt.subplots( ncols=3 )', '', '2022-09-22 09:27:31', '2022-09-22 09:27:31', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b26848-b656', '用矩阵因式分解计算最小二乘(numpy.linalg.lstsq)', 'python3', '0242ac110007-11ed3a12-93b0fc42-b656', 'import numpy\nfrom numpy import linalg\n\nlinalg.lstsq(a, b, rcond=-1)\n\n# a : (M, N) array_like\n# b : {(M,), (M, K)} array_like\n# https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.linalg.lstsq.html', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b26bcc-b656', '获取多列数据', 'python3', '0242ac110007-11ed3a12-93b0ef18-b656', 'cols_names = [\'col_0\', \'col_1\']\nmy_cols_df = my_df[cols_names]', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b26fc8-b656', 'jointplot', 'python3', '0242ac110007-11ed3a12-93b1ab74-b656', 'import seaborn as sns; sns.set(style=\"ticks\", color_codes=True);tips = sns.load_dataset(\"tips\")\ng = sns.JointGrid(x=\"total_bill\", y=\"tip\", data=tips) # 以tips数据集为例\ng = sns.JointGrid(x=\"total_bill\", y=\"tip\", data=tips)\ng.plot(sns.regplot, sns.distplot)', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b272d4-b656', '最大互信息数', 'python3', '0242ac110007-11ed3a12-93b11808-b656', 'import numpy as np\n\nmatrix = np.transpose(np.array(X)).astype(float)\nmine = MINE(alpha=0.6, c=15, est=\"mic_approx\")\nmic_result = []\nfor i in matrix[1:]:\n    mine.compute_score(t_matrix[0], i)\n    mic_result.append(mine.mic())\nreturn mic_result\n\n', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b2754a-b656', '更通用的最小二乘极小化(scipy.optimize)', 'python3', '0242ac110007-11ed3a12-93b0fc42-b656', 'import scipy\nfrom scipy import optimize\n\noptimize.curve_fit(f, xdata, ydata, p0=None, sigma=None, absolute_sigma=False, check_finite=True, bounds=(-inf, inf), method=None, jac=None, **kwargs)\n\n# f : callable\n# xdata : An M-length sequence or an (k,M)-shaped array for functions with k predictors\n# ydata : M-length sequence\n# https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.curve_fit.html', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b277ca-b656', '输出array', 'python3', '0242ac110007-11ed3a12-93b198aa-b656', 'import numpy as np\nprint(my_array) #打印数组\n\n#saving &Loading on disk保存到磁盘\nnp.save(\'my_array\', a) \nnp.savez(\'array.npz\', a, b)\nnp.load(\'my_array.npy\')\n\n#saving &Loading Text files保存到文件\nnp.loadtxt(\"my file.txt\")\nnp.genfromtxt(\"my_file.csv\", delimiter=\',\')\nnp.savetxt(\"marry.txt\", a, delimiter=\" \")\n', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b27a5e-b656', '使用函数新增列', 'python3', '0242ac110007-11ed3a12-93b0ef18-b656', 'def remove_minus_sign(v):\n    return str.replace(\'-\', \' \', max=2)\n\nmy_df[\'col\'] = my_df[\'col\'].map(remove_minus_sign)', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b27cc0-b656', '用最后一个或缺失值的下一个数据填补缺失值', 'python3', '0242ac110007-11ed3a12-93b10048-b656', '# - ffill : propagate last valid observation forward to next valid\n# - backfill : use NEXT valid observation to fill gap\nmy_df[\'col\'] = my_df[\'col\'].fillna(method=\'ffill\')', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b27f22-b656', '用一个由聚合得出的值填补缺失值', 'python3', '0242ac110007-11ed3a12-93b10048-b656', 'grouped_on = \'col_0\' # [\'col_1\', \'col_1\'] # for multiple columns\n\n### Choice of aggregate functions\n## On non-NA values in the group\n## - numeric choice : mean, median, sum, std, var, min, max, prod\n## - group choice : first, last, count\ndef filling_function(v):\n    return v.fillna(v.mean())\n                    \nmy_df[\'col\'] = my_df.groupby(grouped_on)[\'col\'].transform(filling_function)', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b28170-b656', '所有列(交叉)', 'python3', '0242ac110007-11ed3a12-93b24f7a-b656', 'my_df.plot(kind=\'line\', alpha=0.3)', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b283be-b656', '散点图', 'python3', '0242ac110007-11ed3a12-93b24f7a-b656', 'my_df.plot(kind=\'scatter\', x=\'col1\', y=\'col2\',\n    # c=\'col_for_color\', s=my_df[\'col_for_size\']*10\n    );', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b2865c-b656', 'heatmap', 'python3', '0242ac110007-11ed3a12-93b1ab74-b656', 'import numpy as np; np.random.seed(0)\nimport seaborn as sns; sns.set()\nuniform_data = np.random.rand(10, 12)\nsns.heatmap(uniform_data)', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b2888c-b656', 'TSNE-t 分布邻域嵌入算法', 'python3', '0242ac110007-11ed3a12-93b13144-b656', 'import numpy as np\nfrom sklearn.manifold import TSNE\n\nmatrix = np.array(X)\nt_sne = TSNE(n_components=2, random_state=0)\nnp.set_printoptions(suppress=True)\nresult = t_sne.fit(matrix)\nkl_divergence = result.kl_divergence_\nlabel = t_sne.fit_transform(matrix).tolist()\n\nreturn label, kl_divergence\n# X: array-like\n# http://scikit-learn.org/stable/modules/generated/sklearn.manifold.TSNE.html', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b28ae4-b656', '平均数', 'python3', '0242ac110007-11ed3a12-93b11808-b656', 'import numpy as np\nnp.average(np.array(X))\n\n# X: array-like\n# https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.average.html', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b28d46-b656', '基本的数据排序', 'python3', '0242ac110007-11ed3a12-93b0ef18-b656', 'my_df = my_df.sort(\'col\', ascending=False)', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b28f94-b656', '转置', 'python3', '0242ac110007-11ed3a12-93b1043a-b656', 'pivoted = rows.pivot(index=\"type\", columns=\"make\", values=\"qty\")', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b293c2-b656', '组数据的基本信息', 'python3', '0242ac110007-11ed3a12-93b11808-b656', '# columns settings\ngrouped_on = \'col_0\'  # [\'col_0\', \'col_1\'] for multiple columns\naggregated_column = \'col_1\'\n\n### Choice of aggregate functions\n## On non-NA values in the group\n## - numeric choice : mean, median, sum, std, var, min, max, prod\n## - group choice : first, last, count\n## On the group lines\n## - size of the group : size\naggregated_values = my_df.groupby(grouped_on)[aggregated_column].mean()\naggregated_values.name = \'mean\'\n\n# get the aggregate of group\naggregated_values.ix[group]', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b29908-b656', 'tsplot', 'python3', '0242ac110007-11ed3a12-93b1ab74-b656', 'import numpy as np; np.random.seed(22)\nimport seaborn as sns; sns.set(color_codes=True)\nx = np.linspace(0, 15, 31);data = np.sin(x) + np.random.rand(10, 31) + np.random.randn(10, 1)\nsns.tsplot(data=data)', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b2a6e6-b656', '逻辑回归(LR)', 'python3', '0242ac110007-11ed3a12-93b1a2d2-b656', '# http://scikit-learn.org/stable/modules/linear_model.html\nfrom sklearn import linear_model\n\nlr =linear_model.LogisticRegression()  # penalty : str, ‘l1’ or ‘l2’, default: ‘l2’\nlr.fit(X, y)\n\n', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b2a9ca-b656', '基于树模型', 'python3', '0242ac110007-11ed3a12-93b110e2-b656', 'import numpy as np\nfrom sklearn import feature_selection\nfrom sklearn.ensemble import GradientBoostingClassifier\n\nmatrix = np.array(X)\ntarget = np.array(target)\ntemp = feature_selection.SelectFromModel(GradientBoostingClassifier()).fit(matrix, target)\nindx = temp._get_support_mask().tolist()\nscores = get_importance(temp.estimator_).tolist()\nresult = temp.transform(matrix).tolist()\nreturn scores, indx, result\n\n# X: array-like\n# target: array-like\n# http://scikit-learn.org/stable/modules/generated/sklearn.feature_selection.SelectFromModel.html', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b2ac68-b656', '使用条件定位替换值', 'python3', '0242ac110007-11ed3a12-93b0ef18-b656', 'import pandas as pd\n# my_df_orig 是一个pandas dataframe\ncond = (my_df_orig[\'col\'] != value)\nmy_df_orig[\'col\'][cond] = \"other_value\"', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b2aee8-b656', '显示与保存', 'python3', '0242ac110007-11ed3a12-93b0f77e-b656', 'plt.show( ) #显示图像\nplt.saveflg( \"foo.png\" ) #存储\nplt.saveflg( \"foo.png\", transparent = True) \n#存储透明图像\n\n#关闭与清除\nplt.cla( ) #清除axis\nplt.clf( ) #清除整个图像\nplt.close( ) #关闭窗口\n', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b2b172-b656', '自定义', 'python3', '0242ac110007-11ed3a12-93b1c028-b656', '#colors\nplt.plot(x, x, x, x**2, x, x**3)\nax.plot(x, y, alpha = 0.4)\nax.plot(x, y, c=\'k\')\nfig.colorbar(im, orientation=\'horizontal\')\nim = ax.imshow(img, cmap=\'seismic\')\n\n#markers\nfig, ax = plt.subplots()\nax.scatter(x,y,marker=\'.\')\nax.plot(x,y,marker=\'o\')\n\n#linestyles\nplt.plot(x,y,linewidth=4.0)\nplt.plot(x,y,ls=\'solid\')\nplt.plot(x,y,ls=\'--\')\nplt.plot(x,y,\'--\',x**2,y**2,\'-.\')\nplt.setp(lines, color=\'r\',linewidth=4.0)\n\n#Text & Annotations\nax.text(1,-2.1, \n\'Example Graph\', style=\'italic\')\nax.annotate(\"Sine\", xy=(8,0),\nxycoords=\'data\',xytext=(10.5,0), \ntextcoords=\'data\', arrowprops=\ndict(arrowstyle=\"->\",connectionstyle=\"arc3\"),)\n\n#mathtext\nplt.title(r\'$sigma_i=15$\',\n fontsize=20)\n\n#Limits,Legends&Layouts\n#Limites&Autoscaling\nax.margins(x=0.0, y=0.1) \n#Add padding to a plot\nax.axis(\'equal\') \n#Set the aspect ratio of the plot to 1\nax.set(xlim=[0,10.5],ylim=[-1.5,1.5]) \n#Set limits for x- and y-axis\nax.set_xlim(0,10.5) \n#Set limits for x-axis\n\n#Legends\nax.set(title=\'An Example Axes\',\nylabel=\'Y-Axis\',xlabel=\'X-Axis\') \n#Set a title and x- and y-axis labels\nax.legend(loc=\'best\') \n#No overlapping plot elements\n\n#Ticks\nax.xaxis.set(ticks=range(1,5),\nticklabels=[3,100,-12,\"foo\"]) \n#Manually set x-ticks\nax.tick_params(axis=\'y\',\ndirection =\'inout\',length=10) \n#Make y-ticks longer and go in and out\n\n#Subplot Spacing\nfig3.subplots_adjust(wspace=0.5, \nhspace=0.3,left=0.125,right=0.9,\ntop=0.9,bottom=0.1) \n#Adjust the spacing between subplots\nfig.tight_layout() \n#Fit subplots in to the figure area\n\n#Axis Spines\nax1.spines[\'top\'].set_visible(False) \n#Make the top axis line for a plot invisible\nax1.spines[\'bottom\'].set_position((\'outward\',10)) \n#Move the bottom axis line outward', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b2b438-b656', '从dataframe随机抽取N行数据', 'python3', '0242ac110007-11ed3a12-93b0ef18-b656', 'import random\nn = 10\nsample_rows_index = random.sample(range(len(my_df)), 10)\nmy_sample = my_df.take(rows)\nmy_sample_complementary = my_df.drop(rows)', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b2b686-b656', '卡方检验法', 'python3', '0242ac110007-11ed3a12-93b110e2-b656', 'import numpy as np\nfrom sklearn import feature_selection\nfrom sklearn.feature_selection import chi2\n\nmatrix = np.array(X)\ntarget = np.array(target)\ntemp = feature_selection.SelectKBest(chi2, k=k).fit(matrix, target)\nscores = temp.scores_.tolist()\nindx = temp.get_support().tolist()\nresult = temp.transform(matrix).tolist()\nreturn scores, indx, result\n\n# X: array-like\n# target: array-like\n# k: int\n# http://scikit-learn.org/stable/modules/generated/sklearn.feature_selection.SelectKBest.html\n', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b2bb86-b656', '多项式数据变换', 'python3', '0242ac110007-11ed3a12-93b11bd2-b656', 'import numpy as np\nfrom sklearn import preprocessing\n\nraw_result = preprocessing.PolynomialFeatures().fit_transform(np.array(X))\nresult = raw_result.tolist()\n\n# X: array-like\n# http://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.PolynomialFeatures.html', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b2bfaa-b656', '行列数', 'python3', '0242ac110007-11ed3a12-93b11808-b656', '# 获取当前dataframe的形状\nnb_rows = my_df.shape[0]\nnb_cols = my_df.shape[1]', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b2c22a-b656', '图像绘制', 'python3', '0242ac110007-11ed3a12-93b19c92-b656', 'from bokeh.plotting import figure \np1 = figure( plot_width = 300, \ntools = \'pan, box_zoom\' )  \np2 = figure( plot_width = 300, \nplot_height = 300, \nx_range = (0,8), y_range = (0,8) )\np3 = figure( )', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b2c482-b656', '图像绘制', 'python3', '0242ac110007-11ed3a12-93b1c028-b656', '#1D data\nfig, ax = plt.subplots()\nlines = ax.plot(x,y) \n#Draw points with lines or makers connecting them\nax.scatter(x,y)\n#Draw unconnected points, scaled or colored\naxes[0,0].bar([1,2,3],[3,4,5]) \n#Plot vertical rectangles\naxes[1,0].barh([0.5,1,2.5], [0,1,2]) \n#Plot horizontal rectangles\naxes[1,1].axhline(0.45) \n#Draw a horizontal line across axes\naxes[0,1].axvline(0.65) \n#Draw a vertical line across axes\nax.fill(x,y,color=\'blue\') \n#Draw filled polygons\nax.fill_between(x,y,color=\'yellow\') \n#Fill between y-values and o\n\n#2D data or images\nfig, ax = plt.subplots( ) \n#Colormapped or RGB arrays\nim = ax. imshow(img, cmap=\'gist_earth\', \ninterpolation=\'nearest\',vmin=-2,vmax=2)\naxes2[0].pcolor(data2) \n#Pseudocolor plot of 2D array\naxes2[0].pcolormesh(data) \n#Pseudocolor plot of 2D array\nCS = plt.contour(Y,X,U)\n#Plot contours\naxes2[2].contourf(data1) \n#Plot filled contours\naxes2[2] = ax.clabel(CS)\n#Label a contour plot\n\n#Vector Field\naxes[0,1].arrow(0,0,0.5,0.5) \n#Add an arrow to the axes\naxes[1,1].quiver(y,z) \n#Plot a 2D field of arrows\naxes[0,1].streamplot(X,Y,U,V) \n#plot a 2D field of arrows\n\n#Data Distributions\nax1.hist(y) #Plot a histogram\nax3.boxplot(y) \n#make a box and whisker plot\nax3.violinplot(z) \n#make a violin plot\n', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b2c6e4-b656', '数据类型', 'python3', '0242ac110007-11ed3a12-93b198aa-b656', 'np.int64 #64位整数\nnp.float32 #标准双精度浮点\nnp.complex #复杂树已浮点128为代表\nnp.bool #true&false\nnp.object #python object\nnp.string_ #固定长度字符串\nnp.unicode_ #固定长度统一码\n', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b2c932-b656', '用户定义的聚合方程(使用groupby)', 'python3', '0242ac110007-11ed3a12-93b1912a-b656', 'def zscore(x):\n    return (x - x.mean()) / x.std()\n   \nmy_df[\'zscore_col\'] = my_df.groupby(grouped_on)[aggregated_column].transform(zscore)', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b2cb80-b656', '按列里的值过滤或去除数据', 'python3', '0242ac110007-11ed3a12-93b0ef18-b656', 'cond = (my_df[\'col\'] == value)\n\n# multiple values\n# cond = my_df[\'col\'].isin([value1, value2])\n\n# null value\n# cond = my_df[\'col\'].isnull()\n\n# exclude (negate condition)\n# cond = ~cond\n\nmy_records = my_df[cond]', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b2cdd8-b656', '相关性', 'python3', '0242ac110007-11ed3a12-93b11808-b656', 'my_df.corr()', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b2d008-b656', '单一列', 'python3', '0242ac110007-11ed3a12-93b24f7a-b656', 'my_df[\'col_name\'].plot(kind=\'hist\', bins=100)', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b2d256-b656', '中位数', 'python3', '0242ac110007-11ed3a12-93b11808-b656', 'import numpy as np\nnp.median(np.array(X))\n\n# X: array-like\n# https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.median.html', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b2d49a-b656', '对多列数据排序', 'python3', '0242ac110007-11ed3a12-93b0ef18-b656', 'my_df = my_df.sort([\'col_0\', \'col_1\'], ascending=[True, False])', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b2d6f2-b656', '将dataframe的index设为列名', 'python3', '0242ac110007-11ed3a12-93b0ef18-b656', 'my_df_with_col_index = my_df.set_index(\"col\")\n# my_df_col_index.index is [record0_col_val, record1_col_val, ...]', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b2d94a-b656', 'distplot', 'python3', '0242ac110007-11ed3a12-93b1ab74-b656', 'import seaborn as sns, numpy as np,matplotlib.pyplot as plt\n%matplotlib inline\nsns.set(); np.random.seed(0)\nx = np.random.randn(100)\nsns.distplot(x)', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b2db70-b656', 'kdeplot', 'python3', '0242ac110007-11ed3a12-93b1ab74-b656', 'import numpy as np; np.random.seed(10)\nimport seaborn as sns; sns.set(color_codes=True)\nmean, cov = [0, 2], [(1, .5), (.5, 1)]\nx, y = np.random.multivariate_normal(mean, cov, size=50).T\nsns.kdeplot(x,y)', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b2dd96-b656', 'barplot', 'python3', '0242ac110007-11ed3a12-93b1ab74-b656', 'import seaborn as sns; titanic=sns.load_dataset(\'titanic\')\nsns.barplot(x=\"sex\", y=\"survived\", hue=\"class\", data=titanic)', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b2e2f0-b656', '正态分布', 'python3', '0242ac110007-11ed3a12-93b2e0f2-b656', 'import numpy as np\nfrom sklearn import preprocessing\n\nraw_result = preprocessing.StandardScaler().fit_transform(np.array(X))\nresult = raw_result.tolist()\n\n# X: array-like\n# http://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.StandardScaler.html', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b2e656-b656', '去除特定列中的重复数据', 'python3', '0242ac110007-11ed3a12-93b11bd2-b656', 'import pandas as pd\n# my_df 是一个pandas dataframe\nunique_records_for_cols = my_df.drop_duplicates(cols=[\'col_1\', \'col_0\'])', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b2e8cc-b656', '将数据集加载成多个dataframe', 'python3', '0242ac110007-11ed3a12-93b0ef18-b656', 'import pandas as pd\nmy_dataset = pd.read_csv(\"data.csv\")\n\nfor partial_dataframe in my_dataset.iter_dataframes(chunksize=2000):\n    # Insert here applicative logic on each partial dataframe.\n    pass', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b2eb74-b656', '以字典(dict)形式按行写入数据', 'python3', '0242ac110007-11ed3a12-93b0ef18-b656', 'import pandas as pd\npy_recipe_output = pd.read_csv(\"data.csv\")\nwriter = py_recipe_output.get_writer()\n\n# d is of the form :\n#   {\'col_0\': value0, \'col_1\': value1, ...}\n\nfor d in data_to_write:\n    writer.write_row_dict(r)', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b2edcc-b656', '图像设置', 'python3', '0242ac110007-11ed3a12-93b0f77e-b656', '#创建图像绘制窗口\nf, ax = ply.subplots( figsize = ( 5,6 ) )\n\n#seaborn style\nsis.set( ) #重置\nsns.set_style( \"whitegrid\" )\n#设置matplotlib parameters\nsns.set_style( \"ticks\",\n( \"xtick.major.size\": 8, \n\"ytick.major.size\": 8 ) )\nsns.axes_style( \"whitegrid\" ) \n#返回一个参数指引\n\n#context functions\nsns.set_context( \"talk\" ) \n#设置内容为“talk”\nsns.set_context( \"notebook\",\n font_scale = 1.5, \nrc = ( \"lines.linewidth\": 2.5 ) ) \n#设置内容为“notebook”\n\n#color palette\nsns.set_palette( \"husl\",3 )\n #定义color palette\nsns.color_palette( \"husl\" )\nflatui = ( “#9b59b6”,\"#3498db\",\n\"#95a5a6\",\"#e74c3c\",\n\"#34495e\",\"#2ecc71\")\nsns.set_palette( flatui )\n#定义自己的color palette\n', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b2f056-b656', '可视化', 'python3', '0242ac110007-11ed3a12-93b19c92-b656', '#Glyphs\n\n#Scatter markers \np1.circle( np.array( [1,2,3]), \nnp.array([3,2,1]), fill_color = \'white\')\np2.square(np.array([1.5,3.5,5.5]), \n[1,4,3], color = \'blue\', size = 1)\n\n#Line Glyphs: \np1.line( np.array( [1,2,3,4], \n[3,4,5,6], ), line_width = 2)\np2.multi_line(pd.DataFrame(),\npd.DataFrame(),color=\'blue\')\n\n\n\n#Customized Glyphs\n\n#Selection and Non-Selection Glyphs\np = figure( tools = \'box_select\')\np.circle( \'mpg\', \'cyl\', source = cds_df, \nselection_color = \'red\', \nnonselection_alpha = 0.1)\n\n#Hover Glyphs: \nfrom bokeh.models import HoverTool \nhover = HoverTool( tooltips = None, \nmode = \'vline\' )\n\n#Colormapping:\nfrom bokeh.models \nimport CategoricalColorMapper\ncolor_mapper = CategoricalColorMapper\n( factors = [\'US\', \'Asia\', \'Europe\'], \npalette = [\'blue\', \'red\', \'green\'])\np3.circle( \'mpg\', \'cyl\', source = cds_df, \ncolor = dict( field = \'orign\',\ntransform = color_mapper), legend = \'Orign\')\n\n\n\n#Legend Location\n\n#Inside Plot Area: \np.legend.location = \'bottom_left\'\n\n#Outside Plot Area: \nfrom bokeh.models import Legend\nr1 = p2.asterisk( \nnp.array( [1,2,3]), np.array([3,2,1]))\nr2 = p2.line([1,2,3,4], [3,4,5,6])\nLegend = Legend( items = [(\"One\",\n [p1,r1]]), (\"Two\", [r2])], location = (0,-30))\np.add_layout( legend,\'right\')\n\n#Legend Orientation\np.legend.orientation = \"horizontal\"\np.legend.orientation = \"vertical\"\n\n#Legend Background &Border\np.legend.border_line_color = \"navy\"\np.legend.background_fill_color = \"white\"\n\n\n\n#Rows & Columns Layout\n\n#Rows:\nfrom bokeh.layouts import row\nlayout = row( p1,p2,p3)\n\n#Columns \nfrom bokeh.layouts import columns\nlayout = row( column ( p1,p2), p3)\n\n#Nesting Rows&Columns \nlayout = row( column (p1,p2), p3)\n\n#Grid Layout:\nfrom bokeh.layouts import gridplot\nrow1 = [p1, p2]\nrow2 = [p3]\nlayout = gridplot ( [ [p1,p2], [p3]])\n\n#Tabbed Layout\nfrom bokeh.models.widgets import Panel, Tabs\ntab1 = Panel ( child = p1, title = \"tab1\" )\ntab2 = Panel ( child = p1, title = \"tab2\" )\nlayout = Tabs( tabs = [tab1,tab2])\n\n\n\n#Linked Plots\n\n#linked Axes\np2.x_range = p1.x_range\np2.y_range = p1.y_range\n\n#Linked Brushing\np4 = figure( plot_width = 100, \ntools = \'box_select, lasso_select\')\np4.circle( \'mpg\', \'cyl\', source = cds_df)\np5 = figure( plot_width = 200, \ntools = \'box_select, lasso_select\')\np5.circle( \'mpg\', \'hp\', source = cds_df)\nlayout = row( p4, p5)', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b2f2fe-b656', '显示与保存', 'python3', '0242ac110007-11ed3a12-93b19c92-b656', 'show(p1)\nsave(p1)\nshow(layout)\nsave(layout)', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b2f592-b656', '复制array', 'python3', '0242ac110007-11ed3a12-93b198aa-b656', '#复制数组\nh = a.view() \nnp.copy(a)\nh = a.copy()', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b2f7cc-b656', '使用dataframe的index新建列', 'python3', '0242ac110007-11ed3a12-93b0ef18-b656', 'my_df[\'new_col\'] = my_df.index', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b2fa06-b656', '以列为单位审查数据集', 'python3', '0242ac110007-11ed3a12-93b10048-b656', 'my_df.info()', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b2fc86-b656', '可视化', 'python3', '0242ac110007-11ed3a12-93b0ef18-b656', 'import Matplotlib.pyplot as plt\ns.plot()\nplt.show()\n\ndf2.plot()\nplt.show()', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b2feac-b656', '数据组的遍历', 'python3', '0242ac110007-11ed3a12-93b11808-b656', '# columns settings\ngrouped_on = \'col_0\'  # [\'col_0\', \'col_1\'] for multiple columns\n\ngrouped = my_df.groupby(grouped_on)\n\ni = 0\nfor group_name, group_dataframe in grouped:\n    if i > 10:\n        break\n    i += 1\n    print(i, group_name, group_dataframe.mean())  ## mean on all numerical columns\n', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b300f0-b656', '设置聚合方程转置表', 'python3', '0242ac110007-11ed3a12-93b0ef18-b656', 'stats = my_df.pivot_table(\n    rows=[\"make\"],\n    cols=[\"fuel_type\", \"aspiration\"],\n    values=[\"horsepower\"],\n    aggfunc=\'max\',   # aggregation function\n    margins=True     # add subtotals on rows and cols\n)', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b30334-b656', '去除所有任何缺失值的数据条目', 'python3', '0242ac110007-11ed3a12-93b10048-b656', 'records_without_nas = my_df.dropna()', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b30578-b656', '协方差', 'python3', '0242ac110007-11ed3a12-93b11808-b656', 'my_df.cov()\n', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b3097e-b656', '线性判别分析法(LDA)', 'python3', '0242ac110007-11ed3a12-93b13144-b656', 'from sklearn.lda import LDA\nimport numpy as np\nfrom sklearn import preprocessing\n\nmatrix = np.array(X)\ntarget = np.array(target)\ntemp = LDA(n_components=n_components).fit(matrix, target)\ncoef = temp.coef_\nmean = temp.means_\npriors = temp.priors_\nscalings = temp.scalings_\nxbar = temp.xbar_\nlabel = temp.transform(matrix).tolist()\nreturn label, coef.tolist(), mean.tolist(), priors.tolist(), scalings.tolist(), xbar.tolist()\n\n# X: array-like\n# target: array-like\n# n_components: int\n# http://scikit-learn.org/0.15/modules/generated/sklearn.lda.LDA.html', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b30d16-b656', '二值化', 'python3', '0242ac110007-11ed3a12-93b11bd2-b656', 'import numpy as np\nfrom sklearn import preprocessing\n\nraw_result = preprocessing.Binarizer(threshold=t).fit_transform(np.array(X))\nresult = raw_result.tolist()\n\n# X: array-like\n# t: float\n# http://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.Binarizer.html', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b30f96-b656', '伯努利分布', 'python3', '0242ac110007-11ed3a12-93b2e0f2-b656', 'import numpy as np\nfrom sklearn import preprocessing\n\nraw_result = preprocessing.MinMaxScaler().fit_transform(np.array(X))\nresult = raw_result.tolist()\n\n# X: array-like\n# http://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.MinMaxScaler.html', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b311da-b656', '方差', 'python3', '0242ac110007-11ed3a12-93b11808-b656', 'import numpy as np\n\nnp.var(np.array(X))\n\n# X: array-like\n# https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.var.html', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b31414-b656', '使用boolean formula过滤或去除数据', 'python3', '0242ac110007-11ed3a12-93b0ef18-b656', 'import pandas as pd\n# single value\ncond1 = (my_df[\'col_0\'] == value)\ncond2 = (my_df[\'col_1\'].isin([value1, value2]))\n# boolean operators :\n# - negation : ~  (tilde)\n# - or : |\n# - and : &\ncond = (cond1 | cond2)\nmy_records = my_df[cond]', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b31658-b656', '日期', 'python3', '0242ac110007-11ed3a12-93b0ef18-b656', 'df2[\'Date\'] = pd.to_datetime\n(df2[\'Data\'])\ndf2[\'Date\'] = pd.date_range\n(\'2000-1-1\', periods=6, freq =\'M\')\ndates = [datetime(2012,5,1), \ndatetime(2012,5,2)]\nindex = pd.DatetimeIndex(dates)\nindex = pd.date_range\n(datetime(2012,2,1)), end, freq=\'BM\'', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b318b0-b656', '重命名指定列', 'python3', '0242ac110007-11ed3a12-93b0ef18-b656', 'my_df = my_df.rename(columns = {\'col_1\':\'new_name_1\', \'col_2\':\'new_name_2\'})\n', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b31aea-b656', '基于惩罚值', 'python3', '0242ac110007-11ed3a12-93b110e2-b656', 'import numpy as np\nfrom sklearn import feature_selection\nfrom sklearn.linear_model import LogisticRegression\n\nmatrix = np.array(arr0)\ntarget = np.array(target)\ntemp = feature_selection.SelectFromModel(LogisticRegression(penalty=\"l1\", C=0.1)).fit(matrix, target)\nindx = temp._get_support_mask().tolist()\nscores = get_importance(temp.estimator_).tolist()\nresult = temp.transform(matrix).tolist()\nreturn scores, indx, result\n\n# X: array-like\n# target: array-like\n# http://scikit-learn.org/stable/modules/generated/sklearn.feature_selection.SelectFromModel.html', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b31d4c-b656', 'K平均数算法', 'python3', '0242ac110007-11ed3a12-93b11808-b656', 'import numpy as np\nfrom sklearn.cluster import KMeans\n\nk_means = KMeans(k).fit(np.array(X))\nresult = k_means.labels_\nlabel = result.tolist()\nreturn label, k, k_means.cluster_centers_.tolist(), k_means.inertia_\n\n# k: int, k>=2\n# X: array-like\n# http://scikit-learn.org/stable/modules/generated/sklearn.cluster.KMeans.html', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b31fa4-b656', '所有列的单一属性(如最大值， 列的类型为数值型)', 'python3', '0242ac110007-11ed3a12-93b11808-b656', 'my_df.max()', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b3222e-b656', '分类树(Tree)', 'python3', '0242ac110007-11ed3a12-93b1a2d2-b656', '#http://scikit-learn.org/stable/modules/generated/sklearn.tree.DecisionTreeClassifier.html\nfrom sklearn.tree import DecisionTreeClassifier\n\n# criterion = \"gini\" (CART) or \"entropy\" (ID3)\nclf = DecisionTreeClassifier(criterion = \'entropy\' ,random_state = 0)\nclf.fit(X,y)', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b32472-b656', '随机森林(Random Forest)', 'python3', '0242ac110007-11ed3a12-93b1a2d2-b656', '# http://scikit-learn.org/stable/modules/generated/sklearn.ensemble.RandomForestClassifier.html\nfrom sklearn.ensemble import RandomForestClassifier\nimport numpy as np\n\n# criterion: str, \'gini\' for Gini impurity (Default) and “entropy” for the information gain.\nclf = RandomForestClassifier(criterion=\'gini\')  \n# X: array-like, shape = [n_samples, n_features]\n# y: array-like, shape = [n_samples] or [n_samples, n_outputs]\nclf.fit(np.array(X), np.array(y))', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b326de-b656', '支持向量机(SVM)', 'python3', '0242ac110007-11ed3a12-93b1a2d2-b656', '# http://scikit-learn.org/dev/modules/generated/sklearn.svm.SVC.html#sklearn.svm.SVC\nfrom sklearn import svm\nimport numpy as np\n\n# Classifier Option 1: SVC()\nclf = svm.SVC()       # kernel = \'linear\' or \'rbf\' (default) or \'poly\' or custom kernels; penalty C = 1.0 (default)\n# Option 2: NuSVC()\n# clf = svm.NuSVC() \n# Option 3: LinearSVC()\n# clf = svm.LinearSVC()     # penalty : str, ‘l1’ or ‘l2’ (default=’l2’)\nclf.fit(X, y)                # X shape = [n_samples, n_features], y shape = [n_samples] or [n_samples, n_outputs]\n\n# print(clf.support_vectors_) # get support vectors\n# print(clf.support_)         # get indeices of support vectors\n# print(clf.n_support_)       # get number of support vectors for each class\n\nmean_accuracy = clf.score(X,y)\nprint(\"Accuracy: %.3f\"%(mean_accuracy))', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b3295e-b656', '朴素贝叶斯(Naive Bayesian)', 'python3', '0242ac110007-11ed3a12-93b1a2d2-b656', '# http://scikit-learn.org/stable/modules/generated/sklearn.naive_bayes.GaussianNB.html\nfrom sklearn.naive_bayes import GaussianNB\n\ngnb = GaussianNB()\n# predict(test_set或者train_set) 值为你需要预测的数据集\ny_pred = gnb.fit(X, y).predict(X)\nprint(\"Number of mislabeled points out of a total %d points : %d\" % (X.shape[0],(y != y_pred).sum()))', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b32be8-b656', 'AdaBoostClassifier', 'python3', '0242ac110007-11ed3a12-93b1a2d2-b656', '# 决策树集成\nfrom sklearn.ensemble import AdaBoostClassifier\nfrom sklearn.tree import DecisionTreeClassifier\n\nadaboost_dt_clf = AdaBoostClassifier(\n                                    DecisionTreeClassifier(\n                                        max_depth=2,   # 决策树最大深度，默认可不输入即不限制子树深度\n                                        min_samples_split=20, # 内部结点再划分所需最小样本数，默认值为2，若样本量不大，无需更改，反之增大\n                                        min_samples_leaf=5    # 叶子节点最少样本数,默认值为1，若样本量不大，无需更改，反之增大\n                                        ),\n                                    algorithm=\"SAMME\", # boosting 算法 {‘SAMME’, ‘SAMME.R’}, 默认为后者\n                                    n_estimators=200,  # 最多200个弱分类器，默认值为50\n                                    learning_rate=0.8  # 学习率，默认值为1\n                                     )\nadaboost_dt_clf.fit(X,y)', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b33034-b656', 'GBDT(梯度加速决策树)', 'python3', '0242ac110007-11ed3a12-93b1a2d2-b656', '# http://scikit-learn.org/stable/modules/generated/sklearn.ensemble.GradientBoostingClassifier.html#sklearn.ensemble.GradientBoostingClassifier\nfrom sklearn.ensemble import GradientBoostingClassifier\n\ngbdt = GradientBoostingClassifier(max_depth=4,   # 决策树最大深度，默认可不输入，即不限制子树深度\n                                max_features=\"auto\",  # 寻找最优分割的特征数量，可为int,float,\"auto\",\"sqrt\",\"log2\",None:\n                                n_estimators=100 # Boosting阶段的数量，默认值为100。\n                                )\ngbdt.fit(X,y)', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b333cc-b656', 'K-Means', 'python3', '0242ac110007-11ed3a12-93b1a2d2-b656', '# 聚类\n# http://scikit-learn.org/stable/modules/generated/sklearn.cluster.KMeans.html\nfrom sklearn.cluster import KMeans\n\nkmeans = KMeans(\n                n_clusters = 2, # 簇的个数，默认值为8\n                random_state=0  \n                ).fit(X)\n\nprint(kmeans.labels_)\nprint(\"K Clusters Centroids:\n\", kmeans.cluster_centers_)', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b337e6-b656', '散点图（scatterplot）', 'ir', '0242ac110007-11ed3a12-93b33674-b656', '# 加载包裹\nrequire(ggplot2)\nrequire(ggforce)\n# 基本图 \nbasic <- ggplot(data = my_df , \n                aes(x = my_var1 , y = my_var2)) +\n         geom_point(color = \'red\' )\n#根据一个categorical variable (my_var3）改变颜色 \nbasic + geom_point(aes(color = my_var3 ))\n# 加回归线\nbasic + geom_smooth(method = \"lm\")\n# 放大 my_var1 < cutoff 部分\nbasic + facet_zoom(my_var1 < cutoff)', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b33a5c-b656', '条线图（bar chart）', 'ir', '0242ac110007-11ed3a12-93b33674-b656', '# 加载包裹\nrequire(ggplot2)\n# 基本图\nbasic <- ggplot(data = my_df ) + geom_bar(aes(x = my_var1 ))\n# 根据分类数据 my_var2 填色\nbasic + geom_bar(aes(x = my_var1, fill = my_var2 ))\n', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b33cbe-b656', '饼状图（pie chart）', 'ir', '0242ac110007-11ed3a12-93b33674-b656', 'require(ggplot2)\nrequire(dplyr)\n# 整理数据集中每一类别的数目\ndf <- my_df%>%group_by(categorical_var)%>%\n  summarise(count = n() )\nggplot(df, aes(x = factor(1),y = count, \n               fill = categorical_var)) + \n  geom_bar(width = 1,stat = \'identity\') + \n  coord_polar(\'y\')\n', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b33f16-b656', '重命名 x y 轴／标题', 'ir', '0242ac110007-11ed3a12-93b33674-b656', 'myplot_object + labs(title = \"Title\", \n                    caption = \"Your Data Source\", \n                    x = \"Your Independent Variable\", \n                    y = \"Your Dependent Variable\"）\n', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b3418c-b656', '密度图（density plot）', 'ir', '0242ac110007-11ed3a12-93b33674-b656', '# require(ggplot2)\n# 改变bandwidth --> adjust\n# 改变线条粗细 --> size \nggplot(data = my_df, aes(x = quantitative_var)) + \n  geom_density(aes(col = categorical_var), \n               adjust = 1.2, size = 1.5) ', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b3442a-b656', '时间序列线图', 'ir', '0242ac110007-11ed3a12-93b33674-b656', 'require(ggplot2)\nggplot(my_df, aes(x = date, y = value))+ geom_line( )\n# example\ndate <- seq(as.Date(\'2018-1-1\'), as.Date(\'2018-1-20\'), by =1)\nvalue <- runif(20,0,10)  #产生20 个0 到10 之间的随机数字\nmy_df <- data.frame(date, value)\n', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b3465a-b656', '使用自定义颜色', 'ir', '0242ac110007-11ed3a12-93b33674-b656', '# 选取合适的颜色并存进一个变量中\n# https://www.w3schools.com/colors/colors_picker.asp\n# example\nmy_colors <- c(\"#66ccff\", \"#ff9933\", \"#339933\", \"#ff0000\")\n# 固定颜色\ngeom_bar(color = my_color[1])\n# or geom_point/geom_line ...\n# 颜色根据某变量改变，在自定义色盘中选择颜色\ngeom_bar(aes(x = quantitative_var, fill = categorical_var)) + \n  scale_fill_manual(values = my_colors)', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b348d0-b656', '自定义主题（详细）', 'ir', '0242ac110007-11ed3a12-93b33674-b656', '# 可适当增减元素\n# Details: http://ggplot2.tidyverse.org/reference/theme.html\nmy_theme <- theme(\nplot.title = element_text(size = font_size,  family = \"my_font\", \n                          color = \"my_color\", face = \"bold\"),\nplot.subtitle = element_text(...),\nplot.caption = element_text(...),\nlegend.title = element_text(...),\nlegend.text   = element_text(...),\ntext = element_text(...),\naxis.text = element_text(...),\naxis.title = element_text(size = my_size, family = \"my_font\", \n                          color = \"my_color\", face = \"bold\"),\npanel.grid.major = element_line(colour = \"grid_color\", size = grid_size),\npanel.grid.minor = element_line(...),\npanel.background = element_rect(fill = \"background_color\", \n                                colour = \"my_color\",  size = line_size),\naxis.ticks = element_line(color = \"my_color\", size = tick_size)\n )\n\n# 应用主题\n# plot + my_theme ', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b34cb8-b656', '支持向量机（SVM）', 'ir', '0242ac110007-11ed3a12-93b34b50-b656', 'library(e1071)\n# kernel = \'radial\', \'linear\',\'polynomial\', \'sigmoid\'\n# \'gamma\', \'cost\'  控制模型灵活度（model flexibility）\nsvm.model <- svm(formula, data = my_df, \n                               na.action = na.omit, kernel = \'radial\', \n                               gamma = my_gamma, cost = my_cost)', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b34ed4-b656', '自定义主题（简单）', 'ir', '0242ac110007-11ed3a12-93b33674-b656', '在系统主题中选择一个加在plot上\nmy_plot + theme_bw()\n# or theme_void()/ theme_classic()/theme_minimal()/ theme_dark()\n# pick your theme from http://ggplot2.tidyverse.org/reference/ggtheme.html\n', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b35122-b656', 'Adaboost', 'ir', '0242ac110007-11ed3a12-93b34b50-b656', 'library(fastAdaboost)\n# nIter = number of classifiers in adaboost model\nboost.model <- adaboost(formula, data, nIter)', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b353e8-b656', 'Logistic Regression', 'ir', '0242ac110007-11ed3a12-93b34b50-b656', '# family = binomial for classification task with \n# logit link function\n# type ?family for details\nLR.model <- glm(formula, family = binomial, data = my_df)\npredicted.success.probability <- predict(LR.model, newdata, \n                                         type = \"response\") \npredicted.label<- ifelse(predicted.success.probability > 0.5, \n                         1, 0)', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b3588e-b656', 'K Nearest Neighbor', 'ir', '0242ac110007-11ed3a12-93b34b50-b656', 'pred.object<- knn(train, test, cl = label.testset, \n                              k = number.neighbor, prob = T)\n# pred.object 本身就是预测出的标签(class label) \n# 用以下函数得到其他的信息\nattributes(pred.object)$prob \n# to get probability of being in the winning class\n\nattributes(pred.object)$class \n# 如果处理分类任务，会得到 \'factor\' \n\nattributes(pred.object)$levels \n# return possible values of response', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b35c12-b656', 'K-Means', 'ir', '0242ac110007-11ed3a12-93b34b50-b656', '# 用nstart决定需要运行kmeans算法多少次\nkmeans.model <- kmeans(training.data, centers = num.category, \n                       nstart = num.random.set,\n                       iter.max = max.iter.before.stop, \n                       algorithm = \'Lloyd\')\nkmeans.model$centers # group centers\nkmeans.model$cluster # fitted label', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b35e7e-b656', '朴素贝叶斯（Naive Bayesian)', 'ir', '0242ac110007-11ed3a12-93b34b50-b656', 'require(e1071)\n# Details: https://www.r-bloggers.com/understanding-naive-bayes-classifier-using-r/\nNB.model <- naiveBayes(formula, data, laplace = 0 )\nclass.probability <- predict(NB.model, newdata = Titanic, \n                                            type = \'raw\')\nclass.label <- predict(NB.model, newdata = Titanic, \n                                   type = \'class\')', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b360d6-b656', '线性判别式(LDA)', 'ir', '0242ac110007-11ed3a12-93b34b50-b656', 'library(MASS)\n# x must be a matrix/data frame, \n# x is optional when formula is given\nlda.model <- lda(formula, data, x, prior, na.action)', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b3631a-b656', 'Bagging', 'ir', '0242ac110007-11ed3a12-93b34b50-b656', 'library(ipred)\nmodel.bag <- bagging(formula, nbagg, coob = T, \n                                     data = data.train)\npred.y.test.bag <- predict(model.bag, newdata = test.x)', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b36536-b656', '随机森林(Random Forest)', 'ir', '0242ac110007-11ed3a12-93b34b50-b656', 'require(randomForest)\nforest.model <- randomForest(formula, data, \n                             ntree = my_number_tree, \n                             keep.forest = TRUE)\n\n# 找出第N棵树\nNth.tree <- getTree(forest.model, k = N ) \npredict.forest = predict(forest.model, newdata = iris) # 分类', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b36784-b656', '分类树(Tree)', 'ir', '0242ac110007-11ed3a12-93b34b50-b656', 'require(tree)\ntree.model <- tree(formula, data, na.action = na.omit, \n                   mindev = my_cutoff)\n# mindev 控制 overfitting\n\n# 结果可视化\nprint(tree.model)\nplot(tree.model)\n\n# 给画出的树加文字说明（pretty = 0 变量名称不变）\ntext(tree.model, pretty=0) \n\nprediction <- predict(tree.model, newdata, \n                      type = \'class\') # 分类', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b36b58-b656', '用一个值补所有缺失值', 'ir', '0242ac110007-11ed3a12-93b369e6-b656', '# 用一个值补所有缺失值\ndf[is.na(df)] <- my_num', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b36efa-b656', '线性回归(Linear Regression)', 'ir', '0242ac110007-11ed3a12-93b36d88-b656', '# y~.  使用所有的变量进行分析\nlm (formula，data)', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b3712a-b656', 'Lasso & Ridge', 'ir', '0242ac110007-11ed3a12-93b36d88-b656', 'library(glmnet)\n# alpha = 0 for ridge regression\n# alpha = 1 for lasso regresson\nridge.model <- glmnet(x, y, alpha = 0, \n                                     lambda = my_candidate_costs)\nlasso.model <- glmnet(x, y, alpha = 1, \n                                     lambda = my_candidate_costs)\nprediction <- predict(ridge.model, newdataset, \n                                  s = best_cost, type = \"response\")\n  ', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b37378-b656', '样条曲线(Spline)', 'ir', '0242ac110007-11ed3a12-93b36d88-b656', 'smooth.spline(x ＝ my_predictors, y = my_response,\n                       cv = FALSE)', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b375d0-b656', '广义相加模型(GAM)', 'ir', '0242ac110007-11ed3a12-93b36d88-b656', 'require(mgcv)\n# either gam or mgcv package works\n# type ?family.mgcv for details \n\ngam.model <- gam(formula, family, data)', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b37828-b656', '逐步回归法(Stepwise Regression)', 'ir', '0242ac110007-11ed3a12-93b36d88-b656', 'library(MASS)\n# 向前选择\nforward_model <- stepAIC(object, scope, \n                                            direction = \'forward\') \n# object 通常是lm函数的返回值\n# 向后选择\nbackward_model <- stepAIC(object, scope, \n                                               direction = \'backward\')\n# 双向选择\nbidirection_model <- stepAIC(object, scope, \n                                                direction = \'both\')\n', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b37d46-b656', '平均数', 'ir', '0242ac110007-11ed3a12-93b37a80-b656', 'mean(object)', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b38110-b656', '列的分位数', 'ir', '0242ac110007-11ed3a12-93b37a80-b656', 'quantile(object) \n# return 0%, 25%, 50%, 75%, 100%\n\nquantile(object, p) \n# return p% quantile', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b383c2-b656', '多重聚合（组数据）', 'ir', '0242ac110007-11ed3a12-93b37a80-b656', 'library(magrittr)\nlibrary(dplyr)\nmy_new_df = my_df%>%group_by(categorical_var)%>%\n  summarize(quant_var_stat = mean(quant_var))\n# replace mean with other functions', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b38606-b656', '相关性(Correlation)', 'ir', '0242ac110007-11ed3a12-93b37a80-b656', 'cor()\n\n# 皮尔森相关系数\ncor(x,y, method = \"pearson\")\n# method = \'pearson\', \'kendall\', \'spearman\'', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b38854-b656', '移动平均数', 'ir', '0242ac110007-11ed3a12-93b37a80-b656', 'library(pracma)\nmovavg(x, n , type = \'s\')\n# type = \'s\', \'t\', \'w\', \'m\', \'e\', \'r\'\n# n = backward window length', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b38a8e-b656', '中位数', 'ir', '0242ac110007-11ed3a12-93b37a80-b656', 'median()', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b38d22-b656', '列的基本属性', 'ir', '0242ac110007-11ed3a12-93b37a80-b656', 'summary(my_sequence)', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b38f52-b656', '最值', 'ir', '0242ac110007-11ed3a12-93b37a80-b656', '# 最大值\nmax()\n\n# 最小值\nmin()', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b391a0-b656', '值范围', 'ir', '0242ac110007-11ed3a12-93b37a80-b656', 'range()', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b393e4-b656', '数据组基本信息', 'ir', '0242ac110007-11ed3a12-93b37a80-b656', 'summary(my_df)', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b39650-b656', '协方差（covariance)', 'ir', '0242ac110007-11ed3a12-93b37a80-b656', 'cov(x,y)', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b3988a-b656', '标准差', 'ir', '0242ac110007-11ed3a12-93b37a80-b656', 'sd(x)', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b39ab0-b656', '方差', 'ir', '0242ac110007-11ed3a12-93b37a80-b656', 'var()', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b39cd6-b656', '行列数', 'ir', '0242ac110007-11ed3a12-93b37a80-b656', '# 行数\nnum_rows <- nrow(my_df)\n\n# 列数\nnum_cols <- ncol(my_df)', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b39f4c-b656', '排序', 'ir', '0242ac110007-11ed3a12-93b37a80-b656', '# 数据列\nmy_sorted_sequence <- sort(my_sequence, decreasing = FALSE, ...)\n\n# 数据集\nmy_sorted_df <- my_df[order(my_df$sort_var, decreasing = FALSE),]', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b3a190-b656', '筛选数据', 'ir', '0242ac110007-11ed3a12-93b37a80-b656', '# 只选取其中几个变量\nmy_new_df <- subset(my_df, select = c(\'var1\',\'var2\',...))', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b3a73a-b656', '选择特定行', 'ir', '0242ac110007-11ed3a12-93b3a58c-b656', 'my_df[which(my_df$my_var == my_value),]\n# which(my_df$my_var == my_value) 可返回行数\n', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b3aaaa-b656', '查找特别值', 'ir', '0242ac110007-11ed3a12-93b3a58c-b656', 'grep(pattern, my_sequence) \n# 找出序列第几个元素等于pattern', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b3ae56-b656', '导入数据', 'ir', '0242ac110007-11ed3a12-93b3acf8-b656', '# https://www.rstudio.com/resources/cheatsheets/\nrequire(readr)\n\n# 以 , 隔开的数据\nmy_file <- read_csv(\"test_file.csv\")\n\n# 以 ; 隔开的数据\nmy_file <- read_csv2(\"test_file.csv\")\n\n# 以 	 隔开的数据 \nmy_file <- read_tsv(\"test_file.csv\") # or read_table()\n\n# 任何分隔符的数据\nmy_file <- read_delim(\"test_file.csv\", delim = \"my delimiter\") ', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b3b0b8-b656', '导出数据', 'ir', '0242ac110007-11ed3a12-93b3acf8-b656', '# 创建 ， 隔开的数据文档\nwrite_csv(my_df, path, na = \"NA\", append = FALSE,\ncol_names = !append)\n\n# 创建自定义分隔符隔开的数据文档\nwrite_delim(my_df, path, delim = \"my_delimiter\", na = \"NA\",\nappend = FALSE, col_names = !append)\n\n# 创建 	 隔开的数据文档\nwrite_tsv(my_df, path, na = \"NA\", append = FALSE,\ncol_names = !append)\n\n# 利用string创建文档\nwrite_file(my_string, path, append = FALSE)', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b3b310-b656', '设定列名称', 'ir', '0242ac110007-11ed3a12-93b3acf8-b656', '# 不需要列名称\nmy_df <- read_csv(path_to_file, col_names = FALSE)\n\n# 自定义列名称\nmy_df <- read_csv(path_to_file,col_names = c(\'col1\',\'col2\'))', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b3b554-b656', '从第n＋1行开始导入', 'ir', '0242ac110007-11ed3a12-93b3acf8-b656', 'my_file <- read_csv(path_to_file, skip = n)', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b3b77a-b656', '把数据存入一个string里面', 'ir', '0242ac110007-11ed3a12-93b3acf8-b656', 'my_string <- read_file(path, locale = default_locale())', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b3ba36-b656', '每一行导入成一个string', 'ir', '0242ac110007-11ed3a12-93b3acf8-b656', 'my_strings <- read_lines(path, skip = 0, na = character(), locale = default_locale())', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b3bc7a-b656', '自定义列数据类别', 'ir', '0242ac110007-11ed3a12-93b3acf8-b656', '# 默认模式下，readr 自动识别\n# 自定义类型\nmy_df <- read_csv(path_to_file, col_types = cols(\n  var1 = col_double() # numeric\n  var2 = col_integer() # integer\n  ...\n))\n\n# 也可以先随便读取之后parse成自定义类别\nmy_df$var1 <- parse_character(my_df$var1)', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b3c026-b656', '创立date_time object', 'ir', '0242ac110007-11ed3a12-93b3beb4-b656', '# 1970-Jan-1 12:00:00 为时间原点 \ndate_time <- as_datetime(seconds_since_origin)\ndate <- as_date(days_since_origin)', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b3c2e2-b656', 'Parse String得到Date_Time Object', 'ir', '0242ac110007-11ed3a12-93b3beb4-b656', 'x <- my_string\n# example\nx <- c(\"10-04-09\")\nymd(x) # 2010-04-09\nydm(x) # 2010-09-04\nmdy(x) # 2009-10-4\ndmy() #day-month-year\nparse_date_time(\"09/01/01\",\"ymd\")', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b3c562-b656', '当下时间', 'ir', '0242ac110007-11ed3a12-93b3beb4-b656', 'library(lubridate)\nnow(\'my_time_zone\') \ntoday(\'my_time_zone\')', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b3c792-b656', '查询', 'ir', '0242ac110007-11ed3a12-93b3beb4-b656', '# x = time object/string/...\ndate(x)\nyear(x)\nmonth(x)\nday(x)\nwday(x) #星期几\nhour(x)\nminute(x)\nsecond(x)\nweek(x) #一年中第几周\nam(x) # boolean\npm(x) # boolean', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b3cb0c-b656', '时区转换', 'ir', '0242ac110007-11ed3a12-93b3beb4-b656', 'library(lubridate)\nwith_tz(time_object, tzone = \'my_time_zone\')', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b3ce18-b656', '给一个Date Object加减时间', 'ir', '0242ac110007-11ed3a12-93b3beb4-b656', '# example\ndt <- ymd_hms(\"2017-10-20 12:00:00\")\n# 加一年\ndt <- dt + years(1)\n# dt = \"2018-10-20 12:00:00 UTC\"\n# 可加减其他以下period\nmonths()\nweeks()\ndays()\nseconds() # ...', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b3d1ba-b656', '时间换算', 'ir', '0242ac110007-11ed3a12-93b3beb4-b656', 'dyears(x) # 31536000x seconds\ndweeks(x) # 604800x seconds\nddays(x)\ndhours(x)\n# 换算成其他\ndmilliseconds(x)', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b3d41c-b656', '区间(interval)', 'ir', '0242ac110007-11ed3a12-93b3beb4-b656', '# 创建区间\nmy_interval <- interval(time_object1, time_object2)\ndate%within%my_interval # 是否在区间内, boolean\nint_start(x) #查询\nint_end(x)\nint_start(x)<- new_start #重置\nint_end(x) <- new_end \n', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b3d656-b656', '用一个值补一列', 'ir', '0242ac110007-11ed3a12-93b369e6-b656', 'my_sequence[is.na(my_sequence)] <- my_num', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b3d890-b656', '用前一个值或后一个值填补', 'ir', '0242ac110007-11ed3a12-93b369e6-b656', '# previous non-na value\nfill(my_df, NA_sequence,\'down\')\n\n# next non-na value\nfill(my_df, NA_sequence, \'up\')', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b3dac0-b656', '用聚合值填补', 'ir', '0242ac110007-11ed3a12-93b369e6-b656', 'my_sequence[is.na(my_sequence)]<- mean(na.omit(my_sequence))\n# 可把mean换成其他函数', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b3dd04-b656', '去除数据集中指定变量含缺失值的行', 'ir', '0242ac110007-11ed3a12-93b369e6-b656', 'my_new_df <- my_df[!is.na(my_df$target_var),]', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b3df5c-b656', '去除缺失值快捷设定', 'ir', '0242ac110007-11ed3a12-93b369e6-b656', '# remove cases so that results are shorter\nna.omit(my_df,...) \n\n# remove cases when running function, \n# insert NA for results corresponding to NA cases, \n# so results are of the original length \nna.exclude(my_df,...) \n\n# 多数函数中可直接用 \'na.action = ...\' 设定用户喜好\n# example: na.action = na.omit ', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b3e312-b656', '应用函数到一系列对象上', 'ir', '0242ac110007-11ed3a12-93b3e1aa-b656', 'require(purrr)\nmap(.x, my_function)\nmodify(.x, my_function)\n\n# 类似函数包括 map_chr(),  map_df(), map_lgl(),\n# map_int(),map_dbl()\n\n# pair up x and y elements and apply function\nmap2(.x, .y, my_function) \n\n', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b3e54c-b656', '应用函数到特定对象上', 'ir', '0242ac110007-11ed3a12-93b3e1aa-b656', 'modify_at(.x, object_name_or_index, my_function)\n', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b3e77c-b656', '应用一系列函数', 'ir', '0242ac110007-11ed3a12-93b3e1aa-b656', 'invoke_map(function_list, .x = list(NULL), ...)', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b3e9b6-b656', '符合特定条件时应用函数', 'ir', '0242ac110007-11ed3a12-93b3e1aa-b656', 'map_if(object_list, my_function, condition)', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b3ebe6-b656', '测试对象是否满足某条件', 'ir', '0242ac110007-11ed3a12-93b3e1aa-b656', 'every(object_list, condition) \n# all elements pass a test', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b3ef88-b656', '线性回归模型', 'ir', '0242ac110007-11ed3a12-93b3ee0c-b656', 'library(caret)\ncontrol <- rfeControl(functions = lmFuncs, method = \"cv\",\n                   verbose = FALSE,\n                   returnResamp = \"final\")\nRFE_object <- rfe(x, y, sizes = subsets, rfeControl = control)\n\n# 查看选取的特征\npredictors(RFE_object)\n# 查看其他属性\nRFE_object$fit\nRFE_object$resample', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b3f384-b656', '随机森林选取法', 'ir', '0242ac110007-11ed3a12-93b3ee0c-b656', 'library(caret)\nlibrary(randomForest)\n\ncontrol <- rfeControl(functions = rfFuncs, \n                      method = \"cv\", \n                      verbose = FALSE,\n                      returnResamp = \"final\")\nRFE_object <- rfe(x,y, sizes = subsets, \n                  rfeControl = control)', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b3f7e4-b656', 'treeBag 选取法', 'ir', '0242ac110007-11ed3a12-93b3ee0c-b656', 'library(caret)\nlibrary(ipred)\n\ncontrol <- rfeControl(functions = treebagFuncs,\n                      method = \"cv\", verbose = FALSE,\n                      returnResamp = \"final\")\nRFE_object <- rfe(x,y, sizes = subsets, \n                  rfeControl = control)', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b3fab4-b656', '用varImp选取', 'ir', '0242ac110007-11ed3a12-93b3ee0c-b656', '# http://dataaspirant.com/2018/01/15/feature-selection-techniques-r/\nmy_model <- glm(formula, data, family = \"binomial\")\nvarImp(my_model)\n\n# 可用 randomForest(), lm() etc 取代glm', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b3fd16-b656', '使用相关性选取', 'ir', '0242ac110007-11ed3a12-93b3ee0c-b656', 'library(caret)\nvariable_remove <- findCorrelation(cor(my_x), cutoff = my_cutoff)\n# assume each col is a predictor\nmy_new_x <- my_x[,-variable_remove] ', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b3ff50-b656', '蒙特卡罗选取法', 'ir', '0242ac110007-11ed3a12-93b3ee0c-b656', '# https://cran.r-project.org/web/packages/rmcfs/vignettes/jss2621.pdf\noptions(java.parameters = \"-Xmx2g\")\nrequire(rmcfs)\n\nresult <- mcfs(formula, data, \n                        projections = \"auto\",\n                        projectionSize = \"auto\",\n                featureFreq, cutoffPermutations,\n                seed, threadNumber,...)\n\n# 按重要性对特征排序\nplot(result, type = \"features\", \n     size = num_variable_displayed)', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b401e4-b656', 'SBF(Selection by Filters)', 'ir', '0242ac110007-11ed3a12-93b3ee0c-b656', 'require(gam)\nSF_object <- sbf(predictors, outcome, \n    sbfControl = sbfControl(functions = rfSBF, \n                            method = \"cv\", \n                            verbose = FALSE),\n    ...)\n# 或者\nSF_object <- sbf(formula, data, \n    sbfControl = sbfControl(functions = rfSBF,\n                            method = \"cv\", \n                            verbose = FALSE),\n    ...)\n\n# 结果可视化\nprint(SF_object)\ndensity(SF_object)\npredictors(SF_object)\nhistogram(SF_object)', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b4045a-b656', '合并矩阵', 'ir', '0242ac110007-11ed3a12-93b3a58c-b656', '# 按列合并，行数必须一样\ncbind(matrix1,matrix2) \n\n# 按行合并，列数必须一样\nrbind(matrix1,matrix2) ', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b406ee-b656', '更改行列名称', 'ir', '0242ac110007-11ed3a12-93b3a58c-b656', 'colnames(my_df) <- c(\"name1\",\"name2\",\"name3\",\"name4\")\nrownames(my_df) <- c(\"name1\",\"name2\",\"name3\",\"name4\")', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b40996-b656', '对所有行／列操作', 'ir', '0242ac110007-11ed3a12-93b3a58c-b656', '#1 = rows, 2 = cols\napply(x = B,margin = 1, FUN = mean()) ', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b40bda-b656', '创建矩阵', 'ir', '0242ac110007-11ed3a12-93b3a58c-b656', 'A = matrix(c(\"entry1\",\"entry2\",...),\n           nrow = row_num,\n           ncol = col_num,\n           byrow = TRUE) \n#byrow = TRUE 按一行行填数\n\n# n＊n 单位矩阵\nI = diag(1, n)\n\n', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b40e3c-b656', 'Matrix Transpose ', 'ir', '0242ac110007-11ed3a12-93b3a58c-b656', 'A_transpose =  t(A)', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b4104e-b656', '更改／查看数据帧里的值', 'ir', '0242ac110007-11ed3a12-93b3a58c-b656', '# 第c列\nmy_df[,c]\n\n# 第r行\nmy_df[r,]\n\n# 第r行c列的数据\nmy_df[r,c]\n\n# 从c1到ck列\nmy_df[,c1:ck]\n# 其他类似操作\nmy_df[r1:rk,]\nmy_df[r1:rk,c1:ck]', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b412ce-b656', '查看数据帧头几行', 'ir', '0242ac110007-11ed3a12-93b3a58c-b656', 'head(my_df)', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b41670-b656', '主成分分析PCA', 'ir', '0242ac110007-11ed3a12-93b41512-b656', 'pca.object <- prcomp(formula, data, \n                     center = TRUE, \n                     scale = TRUE, \n                     rank = max_dimension, \n                     retx = TRUE)\n\npca.object # access result\n\n# 特征值的柱状图\nlibrary(factoextra)\nfviz_eig(pca.object) # 百分比\nplot(pca.object) # 值\n\n# 得到特征值\neigen_val <- get_eigenvalue(pca.object)\n# 或者\npca.object$sdev^2\n\n# 主成分方向\npca.object$rotation\n', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b41a76-b656', 'LDA降维', 'ir', '0242ac110007-11ed3a12-93b41512-b656', '# LDA\nlda_model <- lda(response_var~., data = my_df)\nresponse_col <- ncol(my_df) # 假设y是最后一列数据\nreduced_df <- as.matrix(my_df[,1:response_col-1])%*%lda_model$scaling', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b41de6-b656', '奇异值分解', 'ir', '0242ac110007-11ed3a12-93b3a58c-b656', 'svd(my_matrix)', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b42084-b656', '创建对角矩阵', 'ir', '0242ac110007-11ed3a12-93b3a58c-b656', '# 输入对角线上的数\ndiag(entry_list) \n\n# 用一个数填满对角线\ndiag(repeating_value, repeating_times)\n', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b422dc-b656', '连接', 'ir', '0242ac110007-11ed3a12-93b3a58c-b656', 'cat(..., file = \"\", fill = FALSE, labels = NULL, append = FALSE)\n# cat(\"my name is\", \"kesci\")\n\n\n\npaste (..., sep = \" \", collapse = NULL)\npaste0(..., collapse = NULL)\n# paste(\"hi\", \"how are you\", sep = \",\")', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b426a6-b656', '方差／标准差变为1', 'ir', '0242ac110007-11ed3a12-93b42548-b656', 'require(caret)\nparameters <- preProcess(my_x, method = c(\"scale\"))\ntransformed<-predict(parameters, my_x)\n', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b428cc-b656', '平均数变为0', 'ir', '0242ac110007-11ed3a12-93b42548-b656', '# center\nrequire(caret)\nparameters <- preProcess(my_x, method = c(\"center\"))\ntransformed <- predict(parameters, my_x)', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b42b06-b656', '平均数变为0且方差变为1', 'ir', '0242ac110007-11ed3a12-93b42548-b656', '# standardize\nrequire(caret)\nparameters <- preProcess(my_x, method = c(\"center\", \"scale\"))\ntransformed <- predict(parameters, my_x)', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b42d68-b656', 'Box-Cox Transform', 'ir', '0242ac110007-11ed3a12-93b42548-b656', 'require(caret)\nparameters <- preProcess(my_x, method = c(\"BoxCox\"))\ntransformed <- predict(parameters, my_x)\n', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b42fac-b656', 'Yeo-Johnson Transform', 'ir', '0242ac110007-11ed3a12-93b42548-b656', 'require(caret)\nparameters <- preProcess(my_x, method = c(\"YeoJohnson\"))\ntransformed <- predict(parameters, my_x)\n', '', '2022-09-22 09:27:32', '2022-09-22 09:27:32', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b431be-b656', '主成分分析', 'ir', '0242ac110007-11ed3a12-93b42548-b656', 'require(caret)\nparameters <- preProcess(my_x, c(\"center\", \"scale\", \"pca\"))\ntransformed <- predict(parameters,my_x)', '', '2022-09-22 09:27:33', '2022-09-22 09:27:33', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b43420-b656', '独立分量分析（ICA）', 'ir', '0242ac110007-11ed3a12-93b42548-b656', 'parameters <- preProcess(my_x, \n                         method = c(\"center\", \"scale\", \"ica\"), \n                         n.comp=5)\n\n# n.comp 想要的独立分量数目\ntransformed <- predict(parameters, my_x)', '', '2022-09-22 09:27:33', '2022-09-22 09:27:33', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b436a0-b656', 'Test Element Membership', 'ir', '0242ac110007-11ed3a12-93b3e1aa-b656', 'has_element(my_list, target)\n# target in object_list', '', '2022-09-22 09:27:33', '2022-09-22 09:27:33', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b438c6-b656', '列表增填', 'ir', '0242ac110007-11ed3a12-93b3a58c-b656', 'append(x, value)\n# Add to the end\n\nprepend(x, value)\n# Add to the start', '', '2022-09-22 09:27:33', '2022-09-22 09:27:33', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b43aec-b656', '聚合成一个list', 'ir', '0242ac110007-11ed3a12-93b3e1aa-b656', '# combine all objects into a list\nsplice(object1, object2, object3,...)', '', '2022-09-22 09:27:33', '2022-09-22 09:27:33', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b43d1c-b656', '给列表元素命名', 'ir', '0242ac110007-11ed3a12-93b3e1aa-b656', 'set_names(my_list, name_vector)\n# name_vector = c(\"name1\", \"name2\",...)', '', '2022-09-22 09:27:33', '2022-09-22 09:27:33', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b4406e-b656', '运行一个函数多次', 'ir', '0242ac110007-11ed3a12-93b3e1aa-b656', 'rerun(n, expression)\n# 运行 expression n 次', '', '2022-09-22 09:27:33', '2022-09-22 09:27:33', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b449c4-b656', '函数wrapper', 'ir', '0242ac110007-11ed3a12-93b3e1aa-b656', '# 以下函数可在运行函数时避免警告,错误等信息\nquietly() \npossibly()\nsafely() ', '', '2022-09-22 09:27:33', '2022-09-22 09:27:33', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b455c2-b656', 'Flatten', 'ir', '0242ac110007-11ed3a12-93b3e1aa-b656', 'flatten(my_nested_list) # return a list\nflatten_int(my_nested_list) # return int object \n# 类似函数包括 flatten_lgl(), flatten_dbl(), flatten_chr()\n# flatten_x returns object of \'x\' type', '', '2022-09-22 09:27:33', '2022-09-22 09:27:33', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b45acc-b656', '查找', 'ir', '0242ac110007-11ed3a12-93b45946-b656', 'require(stringr)\n# return boolean\nstr_detect(string, pattern) \n\n# find indexes of strings with pattern\nstr_which(sequence_of_string, pattern) \n\n# return num_of_occurance \nstr_count(string, pattern)\n\n# return start, end of pattern\nstr_locate(string, pattern)', '', '2022-09-22 09:27:33', '2022-09-22 09:27:33', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b45d06-b656', 'String 片段', 'ir', '0242ac110007-11ed3a12-93b45946-b656', '# inclusive of endpoints\nstr_sub(string, start, end) \n\n# return strings with pattern\nstr_subset(sequence_of_string, pattern) \nstr_extract(string, pattern) ', '', '2022-09-22 09:27:33', '2022-09-22 09:27:33', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b45f4a-b656', '链接和断开', 'ir', '0242ac110007-11ed3a12-93b45946-b656', '# join multiple strings\nstr_c(..., sep = my_seperator, collapse = NULL) \n\nstr_dup(string, times) # 复制\n\nstr_split(..., pattern) #在pattern处断开\n\nstr_split_fixed(...,pattern,n) # 得到矩阵\n\nstr_glue() # input is (formatted) string\n\nstr_glue_data() # input is data frame', '', '2022-09-22 09:27:33', '2022-09-22 09:27:33', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b4618e-b656', '更改', 'ir', '0242ac110007-11ed3a12-93b45946-b656', '# replace the first old_pattern\nstr_sub() <- new_value\nstr_replace(string, old_pattern, new_pattern) \n\n# replace all old_patterns\nstr_replace_all()', '', '2022-09-22 09:27:33', '2022-09-22 09:27:33', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b463be-b656', '大小写', 'ir', '0242ac110007-11ed3a12-93b45946-b656', 'str_to_lower() # 变成小写\nstr_to_upper() # 变成大写\nstr_to_title() # 首字母大写', '', '2022-09-22 09:27:33', '2022-09-22 09:27:33', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b467d8-b656', '排序', 'ir', '0242ac110007-11ed3a12-93b45946-b656', '# 得到string的序号\norder <- str_order(string, decreasing = FALSE) \nstr_sort() # str_sort(x) == x[str_order(x)]', '', '2022-09-22 09:27:33', '2022-09-22 09:27:33', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b46c6a-b656', '在html 文件中查看', 'ir', '0242ac110007-11ed3a12-93b45946-b656', '# 类似于str_extract, str_extract_all\nstr_view(string, pattern)\nstr_view_all(string,pattern)', '', '2022-09-22 09:27:33', '2022-09-22 09:27:33', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b46f30-b656', '矩阵运算', 'ir', '0242ac110007-11ed3a12-93b3a58c-b656', 'A*B # element-wise multiplication\n\nA%*%B # matrix multiplication\n\nA %o% B # outer product ', '', '2022-09-22 09:27:33', '2022-09-22 09:27:33', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b47174-b656', '向量叉积', 'ir', '0242ac110007-11ed3a12-93b3a58c-b656', 'crossprod(A, B) #A^tB  \ncrossprod(A, A) # A^tA\n', '', '2022-09-22 09:27:33', '2022-09-22 09:27:33', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b47386-b656', '求解线性系统', 'ir', '0242ac110007-11ed3a12-93b3a58c-b656', 'solve(A, b)  # find solution to b = Ax', '', '2022-09-22 09:27:33', '2022-09-22 09:27:33', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b47598-b656', '矩阵求逆', 'ir', '0242ac110007-11ed3a12-93b3a58c-b656', 'solve(A)', '', '2022-09-22 09:27:33', '2022-09-22 09:27:33', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b477aa-b656', 'QR Factorization', 'ir', '0242ac110007-11ed3a12-93b3a58c-b656', 'QR_object <- qr(my_matrix)\nOR_object$rank # rank of my_matrix\nQR_object$qraux #Q的信息\nQR_object$pivot #pivoting 策略信息\nQR_object$qr # Q, R 矩阵\n\n', '', '2022-09-22 09:27:33', '2022-09-22 09:27:33', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b479bc-b656', '行列基本计算', 'ir', '0242ac110007-11ed3a12-93b3a58c-b656', 'rowMeans(my_matrix)\nrowSums(my_matrix)\ncolMeans(my_matrix)\ncolSums(my_matrix)', '', '2022-09-22 09:27:33', '2022-09-22 09:27:33', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b47bce-b656', '创建向量', 'ir', '0242ac110007-11ed3a12-93b3a58c-b656', 'seq(start, end, by = step_size)\nseq(start, end, length.out =  vector_length)\n\n# 从start到end的整数\nmy_sequence <- start:end \n\nmy_seq <- c(element1, element2, ...)\n', '', '2022-09-22 09:27:33', '2022-09-22 09:27:33', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b47f3e-b656', 'keras 部署服务', 'python3', '0242ac110007-11ed3a12-93b47dea-b656', 'import tensorflow as tf\n# freeze traiing session\ndef freeze_session(session, keep_var_names=None, output_names=None, clear_devices=True):\n    # get session graph\n    graph = session.graph\n    with graph.as_default():\n        # remove training related nodes\n        freeze_var_names = list(set(v.op.name for v in tf.global_variables()).difference(keep_var_names or []))\n        output_names = output_names or []\n        output_names += [v.op.name for v in tf.global_variables()]\n        input_graph_def = graph.as_graph_def()\n        # remove device info if trained on gpu\n        if clear_devices:\n            for node in input_graph_def.node:\n                node.device = \"\"\n        frozen_graph = tf.graph_util.convert_variables_to_constants(\n            session, input_graph_def, output_names, freeze_var_names)\n        return frozen_graph\n        \nfrom keras import backend as K\nfrozen_graph = freeze_session(K.get_session(),\n                              output_names=[out.op.name for out in model.outputs])\ntf.train.write_graph(frozen_graph, \"./\", \"model.pb\", as_text=False)', '', '2022-09-22 09:27:33', '2022-09-22 09:27:33', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b481aa-b656', '可部署为服务的 Python 脚本', 'python3', '0242ac110007-11ed3a12-93b47dea-b656', '__name__ = \'model\'\n\ndef func(input_object):\n    # your code here\n    return output_object', '', '2022-09-22 09:27:33', '2022-09-22 09:27:33', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b483d0-b656', '使用 keras 做分类', 'python3', '0242ac110007-11ed3a12-93b1a2d2-b656', 'from keras.models import Sequential\nfrom keras.layers.core import Dense, Dropout, Activation\nfrom keras.optimizers import Adam\nfrom keras.utils import np_utils\n\ntraining_epochs = 200 #训练次数，总体数据需要循环多少次\nbatch_size = 10  \n\nmodel = Sequential()\ninput = X.shape[1]\n# 隐藏层128\nmodel.add(Dense(128, input_shape=(input,)))\nmodel.add(Activation(\'relu\'))\n# Dropout层用于防止过拟合\nmodel.add(Dropout(0.2))\n# 隐藏层128\nmodel.add(Dense(256))\nmodel.add(Activation(\'relu\'))\nmodel.add(Dropout(0.2))\n# 没有激活函数用于输出层，二分类问题，用sigmoid激活函数进行变换，多分类用softmax。\nmodel.add(Dense(1))\nmodel.add(Activation(\'sigmoid\'))\n# 使用高效的 ADAM 优化算法以，二分类损失函数binary_crossentropy，多分类的损失函数categorical_crossentropy\nmodel.compile(loss=\'binary_crossentropy\', optimizer=Adam(), metrics=[\'accuracy\'])\n\nhistory = model.fit(X_train, y_train, validation_data=(X_test,y_test), epochs=training_epochs, batch_size=32)\n', '', '2022-09-22 09:27:33', '2022-09-22 09:27:33', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b48628-b656', '使用 keras 做线性回归', 'python3', '0242ac110007-11ed3a12-93b0fc42-b656', 'from keras.models import Sequential #顺序模型\nfrom keras.layers import Dense\n\nn_hidden_1 = 64 #隐藏层1的神经元个数\nn_hidden_2 = 64 #隐藏层2的神经元个数\nn_input = 13 #输入层的个数，也就是特征数\nn_classes = 1 #输出层的个数\ntraining_epochs = 200 #训练次数，总体数据需要循环多少次\nbatch_size = 10  \n\nmodel = Sequential()#先建立一个顺序模型\n#向顺序模型里加入第一个隐藏层，第一层一定要有一个输入数据的大小，需要有input_shape参数\n#model.add(Dense(n_hidden_1, activation=\'relu\', input_shape=(n_input,)))\nmodel.add(Dense(n_hidden_1, activation=\'relu\', input_dim=n_input))\nmodel.add(Dense(n_hidden_2, activation=\'relu\'))\nmodel.add(Dense(n_classes))\n\nmodel.compile(loss=\'mse\', optimizer=\'rmsprop\', metrics=[\'mae\',r2])\n\nhistory = model.fit(X_train, y_train, validation_data=(X_test,y_test), epochs=training_epochs, batch_size=batch_size)', '', '2022-09-22 09:27:33', '2022-09-22 09:27:33', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b48862-b656', '类别转数字', 'python3', '0242ac110007-11ed3a12-93b11bd2-b656', '# Label1 和 Label2 表示 类别\ntarget = pd.Series(map(lambda x: dict(Label1=1, Label2=0)[x], my_df.target_col.tolist()), my_df.index)\nmy_df.target_col = target', '', '2022-09-22 09:27:33', '2022-09-22 09:27:33', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b48a92-b656', '获得类别字段的频数', 'python3', '0242ac110007-11ed3a12-93b11808-b656', 'my_df[\'category\'].value_counts()', '', '2022-09-22 09:27:33', '2022-09-22 09:27:33', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b48da8-b656', '查看缺失情况', 'python3', '0242ac110007-11ed3a12-93b11808-b656', 'for col in my_df.columns:\n    print(\"column {} 包含 {} 个缺失值\".format(col, my_df[col].isnull().sum()))', '', '2022-09-22 09:27:33', '2022-09-22 09:27:33', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b490be-b656', '查看字段包含unique值的程度', 'python3', '0242ac110007-11ed3a12-93b11808-b656', 'for col in my_df.columns:\n    print(\"column {} 中共有 {} 个unique value\".format(col, my_df[col].nunique()))', '', '2022-09-22 09:27:33', '2022-09-22 09:27:33', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b4941a-b656', '特征缩放', 'python3', '0242ac110007-11ed3a12-93b11bd2-b656', 'from sklearn.preprocessing import StandardScaler\nsc = StandardScaler()\nX_train = sc.fit_transform(X_train)\nX_test = sc.transform(X_test)', '', '2022-09-22 09:27:33', '2022-09-22 09:27:33', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b497c6-b656', '连接 PostgreSQL', 'python3', '0242ac110007-11ed3a12-93b49668-b656', 'import psycopg2\nimport pandas as pd\n\nconnection = psycopg2.connect(user = \"username\",\n                                  password = \"password\",\n                                  host = \"127.0.0.1\",\n                                  port = \"5432\",\n                                  database = \"dn_name\")\ncursor = connection.cursor()\n\ntest_query = \"\"\"SELECT subject_id, hadm_id, admittime, dischtime, admission_type, diagnosis\nFROM admissions\n\"\"\"\n\ntest = pd.read_sql_query(test_query, connection)', '', '2022-09-22 09:27:33', '2022-09-22 09:27:33', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b49a46-b656', '单表导出数据', 'python3', '0242ac110007-11ed3a12-93b49668-b656', '## 从单表中获取数据\n## 使用 WHERE 和 HAVING 语句进行过滤\n## 用 order_by_list 字段进行降序排序\n## conn 为 postgreSQL 的数据库连接对象\nquery_string = \"\"\"SELECT [DISTINCT] <select_column_list> [AS <alias_name>]\nFROM <table_name>\nWHERE <where_condition_1> AND <where_condition_2> OR <where_condition_3>\nHAVING <having_condition>\nORDER BY <order_by_list> [DESC]\n\"\"\"\n\ndf = pd.read_sql_query(query_string, conn)\n\n', '', '2022-09-22 09:27:33', '2022-09-22 09:27:33', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b49de8-b656', '连接 PostgreSQL 数据库', 'ir', '0242ac110007-11ed3a12-93b49c8a-b656', 'require(\"RPostgreSQL\")\ndrv <- dbDriver(\"PostgreSQL\")\n\ncon <- dbConnect(drv, dbname = \"dbname\",\n                 host = \"hostname\", \n                 port = 5432,\n                 user = \"username\",\n                 password = \"password)\n\n\ndbSendQuery(con, query)', '', '2022-09-22 09:27:33', '2022-09-22 09:27:33', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b4a00e-b656', '使用 WHERE 语句过滤', 'python3', '0242ac110007-11ed3a12-93b49668-b656', '## 从单表中获取数据\n## 使用 WHERE 语句进行过滤，包含了 IN 包含关系，和使用 LIKE 做模式匹配\n## conn 为 postgreSQL 的数据库连接对象\nquery_string = \"\"\"SELECT [DISTINCT] <select_column_list> [AS <alias_name>]\nFROM <table_name>\nWHERE column_name [NOT] IN ( value_1, value_2, ...,value_n)\nAND column_name BETWEEN value_1 AND value_2\nOR column_name LIKE \'string\'\n\"\"\"\n\ndf = pd.read_sql_query(query_string, conn)\n', '', '2022-09-22 09:27:33', '2022-09-22 09:27:33', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b4a266-b656', '使用 HAVING 语句过滤', 'python3', '0242ac110007-11ed3a12-93b49668-b656', '## 从单表中获取数据\n## 使用 HAVING 语句作过滤，包含聚合函数\n## conn 为 postgreSQL 的数据库连接对象\nquery_string = \"\"\"SELECT [DISTINCT] <select_column_list> [AS <alias_name>]\nFROM <table_name>\nHAVING [aggregation function] = value_1\nAND [aggregation_function] = value_2\n\"\"\"\n\ndf = pd.read_sql_query(query_string, conn)', '', '2022-09-22 09:27:33', '2022-09-22 09:27:33', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b4a4be-b656', '取出前N条数据', 'python3', '0242ac110007-11ed3a12-93b49668-b656', '## 从单表中获取数据\n## 使用 WHERE 和 HAVING 语句进行过滤\n## 用 order_by_list 字段进行降序排序\n## 取出头部的N条数据\n## conn 为 postgreSQL 的数据库连接对象\nquery_string = \"\"\"SELECT [DISTINCT] <select_column_list> [AS <alias_name>]\nFROM <table_name>\nWHERE <where_condition_1> AND <where_condition_2> OR <where_condition_3>\nHAVING <having_condition>\nORDER BY <order_by_list> [DESC]\nLIMIT <selected N>\n\"\"\"\n\ndf = pd.read_sql_query(query_string, conn)', '', '2022-09-22 09:27:33', '2022-09-22 09:27:33', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b4a6f8-b656', '多表导出数据', 'python3', '0242ac110007-11ed3a12-93b49668-b656', '## 从多表中获取数据\n## 使用 INNER JOIN 从两表中获取数据\n## 使用 WHERE 和 HAVING 语句进行过滤\n## conn 为 postgreSQL 的数据库连接对象\nquery_string = \"\"\"SELECT [DISTINCT] <select_column_list>\nFROM <left_table>\n<join_type> JOIN <right_table>\nON <join_condition>  \nWHERE <where_condition>\nHAVING <having_condition>\nORDER BY <order_by_list> DESC\nLIMIT <limit_number>\n\"\"\"\n\ndf = pd.read_sql_query(query_string, conn)', '', '2022-09-22 09:27:33', '2022-09-22 09:27:33', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b4a93c-b656', '使用聚合函数', 'python3', '0242ac110007-11ed3a12-93b49668-b656', '## 从多表中获取数据\n## 使用 INNER JOIN 从两表中获取数据\n## 使用 WHERE 和 HAVING 语句进行过滤\n## conn 为 postgreSQL 的数据库连接对象\nquery_string = \"\"\"SELECT [aggregation function] (<column_name>)\nFROM <left_table>\n<join_type> JOIN <right_table>\nON <join_condition>\nWHERE <where_condition>\nGROUP BY <group_by_all_the_left_columns>\n[HAVING <having_condition>]\n[ORDER BY <order_by_list>]\n[LIMIT <limit_number>]\n\"\"\"\n\ndf = pd.read_sql_query(query_string, conn)', '', '2022-09-22 09:27:33', '2022-09-22 09:27:33', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b4ab80-b656', '使用 Subquery', 'python3', '0242ac110007-11ed3a12-93b49668-b656', '## 如果SQL Query过长过复杂，可把Subquery的结果进行调用\n## conn 为 postgreSQL 的数据库连接对象\n\nquery_string = \"\"\"--subquery作为一张表\nSELECT <column_list> FROM ( \n  SELECT <column_list> FROM table_name\n) AS alias_table_name\n\"\"\"\nquery_string_1 = \"\"\"--subquery作为一系列值\nSELECT <column_list> FROM <table_name>\nWHERE <column_name> IN (\n  SELECT <column_name> FROM <table_name> WHERE  <where_condition>\n)\n\"\"\"\n\ndf = pd.read_sql_query(query_string, conn)', '', '2022-09-22 09:27:33', '2022-09-22 09:27:33', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b4adce-b656', '使用 WITH 语句', 'python3', '0242ac110007-11ed3a12-93b49668-b656', '## 如果SQL Query过长过复杂，可以将子查询的结果定义为表变量在后期复用\n## conn 为 postgreSQL 的数据库连接对象\nquery_string = \"\"\"WITH table_variable_1 AS (\n  <SELECT query>\n),\n\ntable_variable_2 AS (\n  SELECT * FROM table_variable_1;\n)\n\nSELECT * FROM table_variable_2；\n\"\"\"\n\ndf = pd.read_sql_query(query_string, conn)', '', '2022-09-22 09:27:33', '2022-09-22 09:27:33', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b4b012-b656', '通用条件表达式 (类似if-else)', 'python3', '0242ac110007-11ed3a12-93b49668-b656', '## 条件语句\n## conn 为 postgreSQL 的数据库连接对象\nquery_string = \"\"\"-- 通用条件表达式 (类似if-else)\nCASE  \nWHEN condition1 THEN result1 -- i.e WHEN count > 5 THEN 1\nWHEN condition2 THEN result2 -- i.e. WHEN name = \'elle\' THEN \'ELLE\'\n[...]\n[ELSE result_n]\nEND \n\"\"\"\n\ndf = pd.read_sql_query(query_string, conn)\n\n', '', '2022-09-22 09:27:33', '2022-09-22 09:27:33', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b4b288-b656', '单表导出数据', 'ir', '0242ac110007-11ed3a12-93b49c8a-b656', '## 从单表中获取数据\n## 使用 WHERE 和 HAVING 语句进行过滤\n## 用 order_by_list 字段进行降序排序\n## con 为 postgreSQL 的数据库连接对象\nquery = \"SELECT [DISTINCT] <select_column_list> [AS <alias_name>]\nFROM <table_name>\nWHERE <where_condition_1> AND <where_condition_2> OR <where_condition_3>\nHAVING <having_condition>\nORDER BY <order_by_list> [DESC]\n\"\n\ndata = dbGetQuery(con, query)', '', '2022-09-22 09:27:33', '2022-09-22 09:27:33', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b4b698-b656', '使用 WHERE 语句过滤', 'ir', '0242ac110007-11ed3a12-93b49c8a-b656', '## 从单表中获取数据\n## 使用 WHERE 语句进行过滤，包含了 IN 包含关系，和使用 LIKE 做模式匹配\n## con 为 postgreSQL 的数据库连接对象\nquery = \"SELECT [DISTINCT] <select_column_list> [AS <alias_name>]\nFROM <table_name>\nWHERE column_name [NOT] IN ( value_1, value_2, ...,value_n)\nAND column_name BETWEEN value_1 AND value_2\nOR column_name LIKE \'string\'\n\"\n\ndata = dbGetQuery(con, query)', '', '2022-09-22 09:27:33', '2022-09-22 09:27:33', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b4b9fe-b656', '使用 HAVING 语句过滤', 'ir', '0242ac110007-11ed3a12-93b49c8a-b656', '## 从单表中获取数据\n## 使用 HAVING 语句作过滤，包含聚合函数\n## conn 为 postgreSQL 的数据库连接对象\nquery_string = \"SELECT [DISTINCT] <select_column_list> [AS <alias_name>]\nFROM <table_name>\nHAVING [aggregation function] = value_1\nAND [aggregation_function] = value_2\n\"\n\ndata = dbGetQuery(conn, query_string)', '', '2022-09-22 09:27:33', '2022-09-22 09:27:33', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b4bc88-b656', '取出前 N 条数据', 'ir', '0242ac110007-11ed3a12-93b49c8a-b656', '## 从单表中获取数据\n## 使用 WHERE 和 HAVING 语句进行过滤\n## 用 order_by_list 字段进行降序排序\n## 取出头部的N条数据\n## conn 为 postgreSQL 的数据库连接对象\nquery_string = \"SELECT [DISTINCT] <select_column_list> [AS <alias_name>]\nFROM <table_name>\nWHERE <where_condition_1> AND <where_condition_2> OR <where_condition_3>\nHAVING <having_condition>\nORDER BY <order_by_list> [DESC]\nLIMIT <selected N>\n\"\n\ndata = dbGetQuery(conn, query_string)', '', '2022-09-22 09:27:33', '2022-09-22 09:27:33', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b4bee0-b656', '多表导出数据', 'ir', '0242ac110007-11ed3a12-93b49c8a-b656', '## 从多表中获取数据\n## 使用 INNER JOIN 从两表中获取数据\n## 使用 WHERE 和 HAVING 语句进行过滤\n## conn 为 postgreSQL 的数据库连接对象\nquery_string = \"SELECT [DISTINCT] <select_column_list>\nFROM <left_table>\n<join_type> JOIN <right_table>\nON <join_condition>  \nWHERE <where_condition>\nHAVING <having_condition>\nORDER BY <order_by_list> DESC\nLIMIT <limit_number>\n\"\n\ndata = dbGetQuery(conn, query_string)', '', '2022-09-22 09:27:33', '2022-09-22 09:27:33', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b4c138-b656', '使用聚合函数', 'ir', '0242ac110007-11ed3a12-93b49c8a-b656', '## 从多表中获取数据\n## 使用 INNER JOIN 从两表中获取数据\n## 使用 WHERE 和 HAVING 语句进行过滤\n## conn 为 postgreSQL 的数据库连接对象\nquery_string = \"SELECT [aggregation function] (<column_name>)\nFROM <left_table>\n<join_type> JOIN <right_table>\nON <join_condition>\nWHERE <where_condition>\nGROUP BY <group_by_all_the_left_columns>\n[HAVING <having_condition>]\n[ORDER BY <order_by_list>]\n[LIMIT <limit_number>]\n\"\n\ndata = dbGetQuery(conn, query_string)', '', '2022-09-22 09:27:33', '2022-09-22 09:27:33', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b4c368-b656', '使用 Subquery', 'ir', '0242ac110007-11ed3a12-93b49c8a-b656', '## 如果SQL Query过长过复杂，可把Subquery的结果进行调用\n\nquery_string = \"--subquery作为一张表\nSELECT <column_list> FROM ( \n  SELECT <column_list> FROM table_name\n) AS alias_table_name\n\"\nquery_string_1 = \"--subquery作为一系列值\nSELECT <column_list> FROM <table_name>\nWHERE <column_name> IN (\n  SELECT <column_name> FROM <table_name> WHERE  <where_condition>\n)\n\"', '', '2022-09-22 09:27:33', '2022-09-22 09:27:33', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b4c5c0-b656', '使用 WITH 语句', 'ir', '0242ac110007-11ed3a12-93b49c8a-b656', '## 如果SQL Query过长过复杂，可以将子查询的结果定义为表变量在后期复用\n## con 为 postgreSQL 的数据库连接对象\nquery_string = \"\"\"WITH table_variable_1 AS (\n  <SELECT query>\n),\n\ntable_variable_2 AS (\n  SELECT * FROM table_variable_1;\n)\n\nSELECT * FROM table_variable_2；\n\"\"\"\n\ndata = dbGetQuery(con, query_string)', '', '2022-09-22 09:27:33', '2022-09-22 09:27:33', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b4c7fa-b656', '通用条件表达式(类似 if -else)', 'ir', '0242ac110007-11ed3a12-93b49c8a-b656', '## 条件语句\n## con 为 postgreSQL 的数据库连接对象\nquery_string = \"-- 通用条件表达式 (类似if-else)\nCASE  \nWHEN condition1 THEN result1 -- i.e WHEN count > 5 THEN 1\nWHEN condition2 THEN result2 -- i.e. WHEN name = \'elle\' THEN \'ELLE\'\n[...]\n[ELSE result_n]\nEND \n\"\n\ndata = dbGetQuery(con, query_string)', '', '2022-09-22 09:27:33', '2022-09-22 09:27:33', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b4ca8e-b656', '查看数据库中所有表名', 'python3', '0242ac110007-11ed3a12-93b49668-b656', '## 查看数据库中所有表名\n## conn 为 postgreSQL 的数据库连接对象\nquery_string = \"\"\"\nSELECT * FROM pg_tables\nWHERE schemaname <> \'pg_catalog\' AND schemaname <> \'information_schema\'; \n\"\"\"\n\ndf = pd.read_sql_query(query_string, conn)', '', '2022-09-22 09:27:33', '2022-09-22 09:27:33', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b4ccc8-b656', '窗口函数', 'python3', '0242ac110007-11ed3a12-93b49668-b656', '## 窗口函数\n## conn 为 postgreSQL 的数据库连接对象\nquery_string = \"\"\"SELECT <<column_name>,\n       window_func() OVER ( [PARTITION BY xx] [ORDER BY xx] )\nFROM <table_name>\n\"\"\"\n\ndf = pd.read_sql_query(query_string, conn)', '', '2022-09-22 09:27:33', '2022-09-22 09:27:33', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b4cf16-b656', '查看表内字段类型', 'python3', '0242ac110007-11ed3a12-93b49668-b656', '## 查看表内字段类型\n## conn 为 postgreSQL 的数据库连接对象\nquery_string = \"\"\"\nselect column_name, data_type \nfrom information_schema.columns \nwhere table_name = <table_name>\n\"\"\"\n\ndf = pd.read_sql_query(query_string, conn)', '', '2022-09-22 09:27:33', '2022-09-22 09:27:33', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b4d146-b656', '查看表内字段类型', 'ir', '0242ac110007-11ed3a12-93b49c8a-b656', '## 查看表内字段类型\n## conn 为 postgreSQL 的数据库连接对象\nquery_string = \"\nselect column_name, data_type \nfrom information_schema.columns \nwhere table_name = <table_name>\n\"\n\ndata = dbGetQuery(conn, query_string)', '', '2022-09-22 09:27:33', '2022-09-22 09:27:33', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b4d376-b656', '查看数据库中所有表名', 'ir', '0242ac110007-11ed3a12-93b49c8a-b656', '## 查看数据库中所有表名\n## conn 为 postgreSQL 的数据库连接对象\nquery_string = \"\nSELECT * FROM pg_tables\nWHERE schemaname <> \'pg_catalog\' AND schemaname <> \'information_schema\'; \n\"\ndata = dbGetQuery(conn, query_string)', '', '2022-09-22 09:27:33', '2022-09-22 09:27:33', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b4d5e2-b656', '窗口函数', 'ir', '0242ac110007-11ed3a12-93b49c8a-b656', '## 窗口函数\n## conn 为 postgreSQL 的数据库连接对象\nquery_string = \"SELECT <<column_name>,\n       window_func() OVER ( [PARTITION BY xx] [ORDER BY xx] )\nFROM <table_name>\n\"\n\ndata = dbGetQuery(conn, query_string)', '', '2022-09-22 09:27:33', '2022-09-22 09:27:33', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b4d966-b656', '装包换源-Python', 'python3', '0242ac110007-11ed3a12-93b4d808-b656', '!pip install package_name -i https://pypi.douban.com/simple/ #从指定镜像下载安装工具包，镜像URL可自行修改', '', '2022-09-22 09:27:33', '2022-09-22 09:27:33', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b4dca4-b656', '装包换源-R', 'ir', '0242ac110007-11ed3a12-93b4d808-b656', 'install.packages(\'package_name\')\noptions(\"repos\" = c(CRAN=\"https://mirrors.tuna.tsinghua.edu.cn/CRAN/\"))#从指定镜像下载安装工具包，镜像URL可自行修改', '', '2022-09-22 09:27:33', '2022-09-22 09:27:33', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110007-11ed3a12-93b4df9c-b656', '静默安装-Python', 'python3', '0242ac110007-11ed3a12-93b4d808-b656', '!pip install package_name -q', '', '2022-09-22 09:27:33', '2022-09-22 09:27:33', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110019-11ed2904-ed7cfdda-bb46', '函数测试', 'python3', '0242ac001122-11ed5436-fbe0a6bc-9abc', 'print(find_weather(\"上海\"))', NULL, '2022-11-08 16:54:09', '2022-11-08 16:54:14', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('0242ac110019-11ed2904-ed7cfdda-bb47', '函数示例', 'python3', '0242ac001122-11ed5436-fbe0a6bc-9abc', 'import json\nimport urllib.request\n\n__MODULE_NAME__ = \"find_weather\"\n\ndef find_weather(city) -> \"HTTP\":\n  \"\"\"\n    {\n    \"input\":{\"city\":{\"type\":\"String\",\"default\":\"城市\"}},\n   \"output\":{\"weatherinfo\":{\"city\":\"上海\",\"cityid\":\"101020100\",\"temp\":\"23.5\",\"WD\":\"东北风\",\"WS\":\"小于3级\",\"SD\":\"80%\",\"AP\":\"1006.4hPa\",\"njd\":\"2903\",\"WSE\":\"1\"}}\n    }\n  \"\"\"\n  dict = {\"上海\":\"101020100\",\"北京\":\"101010100\",\"武汉\":\"101200101\"}\n  r = urllib.request.urlopen(\'http://www.weather.com.cn/data/sk/\'+dict.get(city)+\'.html\')\n  return json.loads(r.read().decode())', NULL, '2022-11-08 16:54:09', '2022-11-08 16:54:14', 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('12fac190-6a51-11ed-b17f-57ea6b8c9096', 'text', 'python3', NULL, 'text', 'text', NULL, NULL, 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('13a4d804-6a49-11ed-a1f2-7bff3631503d', 'Pandas setup', 'python3', '', 'pip install pandas  #Install Pandas library\r\nimport pandas as pd  #Import Pandas\r\ndf = (pd.melt(df).rename(columns={\'variable\': \'var\'}).query(\'val >= 200\'))  #Method Chaining\r\ndf[(df[\'col_1\']==\'a\')&(df[\'col_2\']>=10)]  #Pandas syntax', 'TEMP', NULL, NULL, 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('3c6dc6bc-6ace-11ed-8ba2-1d8599a82a42', 'Pandas setup', 'python3', '547fb106-697c-11ed-93ea-507b9df4d741', 'pip install pandas  #Install Pandas library\r\nimport pandas as pd  #Import Pandas\r\ndf = (pd.melt(df).rename(columns={\'variable\': \'var\'}).query(\'val >= 200\'))  #Method Chaining\r\ndf[(df[\'col_1\']==\'a\')&(df[\'col_2\']>=10)]  #Pandas syntax', 'TEMP', NULL, NULL, 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('3f29f6be-6ace-11ed-8ba2-1d8599a82a42', 'Data Structures', 'python3', '547fb106-697c-11ed-93ea-507b9df4d741', 's = pd.Series([\'a\', \'b\', \'c\'], index=[0 , 1, 2])  #Create new Series\r\ndf = pd.DataFrame({\'col_1\': [11, 12, 13],\'col_2\': [21, 22, 23],\'col_3\': [31, 32, 33]},index=[0, 1, 2])  #Create new DataFrame', 'TEMP', NULL, NULL, 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('42ab35a0-6ace-11ed-8ba2-1d8599a82a42', 'Read', 'python3', '547fb106-697c-11ed-93ea-507b9df4d741', 'pd.read_csv(filename)  #From a CSV file\r\npd.read_csv(filename, header=None, nrows=5)  #From a CSV file with parameters\r\npd.read_excel(filename)  #From an Excel file\r\npd.read_sql(query, connection_object)  #Reads from a SQL table/database\r\npd.read_json(json_string)  #Reads from a JSON formatted string, URL or file.', 'TEMP', NULL, NULL, 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('45adb660-6ace-11ed-8ba2-1d8599a82a42', 'Write', 'python3', '547fb106-697c-11ed-93ea-507b9df4d741', 'df.to_csv(filename)  #Writes to a CSV file\r\ndf.to_excel(filename)  #Writes to an Excel file\r\ndf.to_json(filename)  #Writes to a file in JSON format\r\ndf.to_html(filename)  #Saves as an HTML table', 'TEMP', NULL, NULL, 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('4a622114-6ace-11ed-8ba2-1d8599a82a42', 'Inspect Data', 'python3', '547fb106-697c-11ed-93ea-507b9df4d741', 'df.head(n)  #First n rows\r\ndf.tail(n)  #Last n rows\r\ndf.shape  #Number of rows and columns\r\ndf.info()  #Index, Datatype and Memory information\r\ndf.describe()  #Summary statistics for numerical columns\r\ns.value_counts(dropna=False)  #(Series) Views unique values and counts\r\ndf.sample(n)  #Randomly select n rows.\r\ndf.nlargest(n, \'col_1\')  #Select and order top n entries for column\r\ndf.nsmallest(n, \'col_1\')  #Select and order bottom n entries.\r\ndf.quantile([0.25,0.75])  #Quantiles of each object', 'TEMP', NULL, NULL, 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('4f033910-6ace-11ed-8ba2-1d8599a82a42', 'Select', 'python3', '547fb106-697c-11ed-93ea-507b9df4d741', 's.loc[0]  #(Series) Select by index\r\ns.iloc[0]  #(Series) Select by position\r\ndf[\'col_1\']  #Get single column as Series\r\ndf[[\'col_1\', \'col_2\']]  #Get multiple columns as a DataFrame\r\ndf.iloc[0,:]  #Select first row from DataFrame\r\ndf.iloc[0,0]  #First element of first column\r\ndf.loc[df[\'col_1\'] > 10, [\'col_1\', \'col_2\']]  #Select rows meeting logical condition, and only the specific columns\r\ndf.iat[1, 2]   #Access single value by index\r\ndf.at[3, \'col_2\']  # Access single value by label', 'TEMP', NULL, NULL, 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('525bd144-6ace-11ed-8ba2-1d8599a82a42', 'Add rows/columns', 'python3', '547fb106-697c-11ed-93ea-507b9df4d741', 'df[\'new col\'] = df[\'col\'] * 100  #Add new column based on other column\r\ndf[\'new col\'] = False  #Add new column single value\r\ndf.loc[-1] = [1, 2, 3]  #Add new row at the end of DataFrame\r\ndf.append(df2, ignore_index = True)  #add rows from DataFrame to existing DataFrame', 'TEMP', NULL, NULL, 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('563c59aa-6ace-11ed-8ba2-1d8599a82a42', 'Drop rows/columns/nan', 'python3', '547fb106-697c-11ed-93ea-507b9df4d741', 's.drop([0, 1])  #(Series) Drop values from Series by index (row axis)\r\ndf.drop(\'col_1\' , axis=1)   #Drop column by name col_1 (column axis)\r\ndf.dropna()  #Drops all rows that contain null values\r\ndf.dropna(axis=1)  #Drops all columns that contain null values\r\ndf.dropna(axis=1,thresh=n)  #Drops all rows have have less than n non null values', 'TEMP', NULL, NULL, 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('5a77268a-6ace-11ed-8ba2-1d8599a82a42', 'Sort values/index', 'python3', '547fb106-697c-11ed-93ea-507b9df4d741', 'df.sort_values(by=\'col_1\', ascending=False)  #Sort values by column, ascending order\r\ndf.sort_values(by=[\'col_1\', \'col_2\'])  #Sort values by columns\r\ndf.sort_index(ascending=False)  #Sort object by labels (along an axis) in descending order\r\ndf.sort_values(by=[(\'col_1\', \'col_2\')])  #Sort multindex by multiple levels\r\ndf.reset_index()  #Reset the index of the DataFrame, moving index to columns', 'TEMP', NULL, NULL, 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('5f6e85ca-6ace-11ed-8ba2-1d8599a82a42', 'Filter', 'python3', '547fb106-697c-11ed-93ea-507b9df4d741', 'df[df[\'col_1\'] > 100]  #Values greater than X\r\ndf[(df[\'col_1\']==\'a\')&(df[\'col_2\']>=10)]  #Filter Multiple Conditions - & - and; | - or\r\ndf[df[\'date\'] > \'2022-02-22\']  #Date filtering\r\ndf[df[\'date\'].dt.month == 2]  #Filter with dt attributes\r\ndf[df[\'col_1\'].str.contains(\'pan*\', regex=True)]  #Filter by regex\r\ndf[df[\'col_1\'].isin([\'pan\', \'das\'])]  #Filter based on list of values\r\ndf.query(\'col_1 > 100\')  #Filter by queries\r\ndf.query(\'col_1 > 100 and col_2 = 0\')  #Filter by multiple queries', 'TEMP', NULL, NULL, 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('64768540-6ace-11ed-8ba2-1d8599a82a42', 'Group by', 'python3', '547fb106-697c-11ed-93ea-507b9df4d741', 'df.groupby(\'col_1\')  #Group by single column - return pandas.core.groupby.DataFrameGroupBy\r\ndf.groupby([\'col_1\', \'col_2\'])  #Group by multiple columns\r\ndf.groupby(\'col_1\').groups  #View groups\r\ndf.groupby(\'col_1\').get_group(1)  #Get group\r\ndf.groupby(\'col_1\').count()  #Get count per groups\r\ndf.groupby(\'col_1\').agg([np.sum, np.mean])  #Apply multiple agg functions on group\r\ndf.groupby(\'col_1\').filter(lambda x: len(x) >= 5)  #Filter groups\r\ndf.groupby(\'col_1\').agg(\'count\')  #Aggregate group using function.\r\ndf.groupby(\'col_1\').rank(method=\'dense\')  #Compute numerical data ranks (1 through n) along axis.', 'TEMP', NULL, NULL, 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('687251e2-6ace-11ed-8ba2-1d8599a82a42', 'Convert', 'python3', '547fb106-697c-11ed-93ea-507b9df4d741', 'df[\'points\'].astype(str)  #convert to string\r\ndf[\'col_1\'].astype(\'int64\')  #convert to int64\r\ndf[\'col_1\'].astype(float)  #convert to float\r\npd.to_numeric(df[\'col_1\'], errors=\'coerce\')  #convert to numeric\r\npd.to_datetime(df[\'date\'], format=\'%Y-%m-%d\')  #convert string to date\r\npd.DataFrame(df[\'Values\'].tolist(), columns=[\'col_1\', \'col_1\'])  #Split column list to multiple columns\r\ndf[\'col_1\'].apply(pd.Series)  #Expand Series of dictionnaries', 'TEMP', NULL, NULL, 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('6c6986ee-6ace-11ed-8ba2-1d8599a82a42', 'Merge & Concat', 'python3', '547fb106-697c-11ed-93ea-507b9df4d741', 'df1.append(df2)  #Adds the rows in df1 to the end of df2 (columns should be identical)\r\npd.concat([df1, df2],axis=1)  #Adds the columns in df1 to the end of df2 (rows should be identical)\r\ndf1.join(df2,on=col1,how=\'inner\')  #SQL-style joins the columns in df1 with the columns on df2 where the rows for col have identical values. how can be one of \'left\', \'right\', \'outer\', \'inner\'', 'TEMP', NULL, NULL, 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('6f2631de-6ace-11ed-8ba2-1d8599a82a42', 'Apply', 'python3', '547fb106-697c-11ed-93ea-507b9df4d741', 'def calc(x):return x + 1\r\ndf.apply(calc, axis = 1)  #Apply function to DataFrame\r\ndf[[\'col_1\',\'col_2\']].apply(calc)  #Apply to multiple columns\r\ndf.apply(lambda x: x * -1 if x < 0 else x)  #Apply lambda', 'TEMP', NULL, NULL, 1);
INSERT INTO `tb_snb_sys_codebase` VALUES ('d20b0e56-9223-11ed-aac1-452284a7d112', 'www', 'python3', 'c40898dc-9223-11ed-aac1-452284a7d112', 'aaa', 'aaa', NULL, NULL, 0);
COMMIT;

-- ----------------------------
-- Table structure for tb_snb_sys_codebase_folder
-- ----------------------------
DROP TABLE IF EXISTS `tb_snb_sys_codebase_folder`;
CREATE TABLE `tb_snb_sys_codebase_folder` (
  `uid` varchar(36) COLLATE utf8_bin NOT NULL COMMENT '代码目录UID',
  `name` varchar(45) COLLATE utf8_bin DEFAULT NULL COMMENT '名称',
  `status` int(11) DEFAULT NULL,
  `create_time` datetime DEFAULT NULL,
  `update_time` datetime DEFAULT NULL,
  PRIMARY KEY (`uid`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin ROW_FORMAT=DYNAMIC COMMENT='代码库目录';

-- ----------------------------
-- Records of tb_snb_sys_codebase_folder
-- ----------------------------
BEGIN;
INSERT INTO `tb_snb_sys_codebase_folder` VALUES ('0242ac001122-11ed5436-fbe0a6bc-9abc', 'FaaS操作', 1, '2022-11-08 16:50:28', '2022-11-08 16:50:56');
INSERT INTO `tb_snb_sys_codebase_folder` VALUES ('0242ac110007-11ed3a12-93b0ef18-b656', 'Pandas基本操作', 1, '2022-09-22 09:27:33', '2022-09-22 09:27:33');
INSERT INTO `tb_snb_sys_codebase_folder` VALUES ('0242ac110007-11ed3a12-93b0f77e-b656', 'Seaborn基本操作', 1, '2022-09-22 09:27:33', '2022-09-22 09:27:33');
INSERT INTO `tb_snb_sys_codebase_folder` VALUES ('0242ac110007-11ed3a12-93b0fc42-b656', '线性回归', 1, '2022-09-22 09:27:33', '2022-09-22 09:27:33');
INSERT INTO `tb_snb_sys_codebase_folder` VALUES ('0242ac110007-11ed3a12-93b10048-b656', '缺失值处理', 1, '2022-09-22 09:27:33', '2022-09-22 09:27:33');
INSERT INTO `tb_snb_sys_codebase_folder` VALUES ('0242ac110007-11ed3a12-93b1043a-b656', '基础维度变化', 1, '2022-09-22 09:27:33', '2022-09-22 09:27:33');
INSERT INTO `tb_snb_sys_codebase_folder` VALUES ('0242ac110007-11ed3a12-93b110e2-b656', '特征选取', 1, '2022-09-22 09:27:33', '2022-09-22 09:27:33');
INSERT INTO `tb_snb_sys_codebase_folder` VALUES ('0242ac110007-11ed3a12-93b11808-b656', '描述性统计信息', 1, '2022-09-22 09:27:33', '2022-09-22 09:27:33');
INSERT INTO `tb_snb_sys_codebase_folder` VALUES ('0242ac110007-11ed3a12-93b11bd2-b656', '数据清洗', 1, '2022-09-22 09:27:33', '2022-09-22 09:27:33');
INSERT INTO `tb_snb_sys_codebase_folder` VALUES ('0242ac110007-11ed3a12-93b13144-b656', '降维', 1, '2022-09-22 09:27:33', '2022-09-22 09:27:33');
INSERT INTO `tb_snb_sys_codebase_folder` VALUES ('0242ac110007-11ed3a12-93b1912a-b656', '新建列', 1, '2022-09-22 09:27:33', '2022-09-22 09:27:33');
INSERT INTO `tb_snb_sys_codebase_folder` VALUES ('0242ac110007-11ed3a12-93b198aa-b656', 'Numpy基本操作', 1, '2022-09-22 09:27:33', '2022-09-22 09:27:33');
INSERT INTO `tb_snb_sys_codebase_folder` VALUES ('0242ac110007-11ed3a12-93b19c92-b656', 'Bokeh基本操作', 1, '2022-09-22 09:27:33', '2022-09-22 09:27:33');
INSERT INTO `tb_snb_sys_codebase_folder` VALUES ('0242ac110007-11ed3a12-93b1a2d2-b656', '分类器', 1, '2022-09-22 09:27:33', '2022-09-22 09:27:33');
INSERT INTO `tb_snb_sys_codebase_folder` VALUES ('0242ac110007-11ed3a12-93b1ab74-b656', 'seaborn可视化', 1, '2022-09-22 09:27:33', '2022-09-22 09:27:33');
INSERT INTO `tb_snb_sys_codebase_folder` VALUES ('0242ac110007-11ed3a12-93b1c028-b656', 'Matplotlib基本操作', 1, '2022-09-22 09:27:33', '2022-09-22 09:27:33');
INSERT INTO `tb_snb_sys_codebase_folder` VALUES ('0242ac110007-11ed3a12-93b24f7a-b656', '以pandas dataframe作图', 1, '2022-09-22 09:27:33', '2022-09-22 09:27:33');
INSERT INTO `tb_snb_sys_codebase_folder` VALUES ('0242ac110007-11ed3a12-93b2e0f2-b656', '无量纲化', 1, '2022-09-22 09:27:33', '2022-09-22 09:27:33');
INSERT INTO `tb_snb_sys_codebase_folder` VALUES ('0242ac110007-11ed3a12-93b33674-b656', 'R-ggplot数据可视化', 0, '2022-09-22 09:27:33', '2022-09-22 09:27:33');
INSERT INTO `tb_snb_sys_codebase_folder` VALUES ('0242ac110007-11ed3a12-93b34b50-b656', 'R-分类器(Classification)', 0, '2022-09-22 09:27:33', '2022-09-22 09:27:33');
INSERT INTO `tb_snb_sys_codebase_folder` VALUES ('0242ac110007-11ed3a12-93b369e6-b656', 'R-缺失数据处理(NA Value)', 0, '2022-09-22 09:27:33', '2022-09-22 09:27:33');
INSERT INTO `tb_snb_sys_codebase_folder` VALUES ('0242ac110007-11ed3a12-93b36d88-b656', 'R-回归分析(Regression)', 0, '2022-09-22 09:27:33', '2022-09-22 09:27:33');
INSERT INTO `tb_snb_sys_codebase_folder` VALUES ('0242ac110007-11ed3a12-93b37a80-b656', 'R-描述性统计信息', 0, '2022-09-22 09:27:33', '2022-09-22 09:27:33');
INSERT INTO `tb_snb_sys_codebase_folder` VALUES ('0242ac110007-11ed3a12-93b3a58c-b656', 'R-基础功能(Base)', 0, '2022-09-22 09:27:33', '2022-09-22 09:27:33');
INSERT INTO `tb_snb_sys_codebase_folder` VALUES ('0242ac110007-11ed3a12-93b3acf8-b656', 'R-导入／导出数据', 0, '2022-09-22 09:27:33', '2022-09-22 09:27:33');
INSERT INTO `tb_snb_sys_codebase_folder` VALUES ('0242ac110007-11ed3a12-93b3beb4-b656', 'R-Date-Time处理(Lubridate)', 0, '2022-09-22 09:27:33', '2022-09-22 09:27:33');
INSERT INTO `tb_snb_sys_codebase_folder` VALUES ('0242ac110007-11ed3a12-93b3e1aa-b656', 'R-函数应用(Purrr)', 0, '2022-09-22 09:27:33', '2022-09-22 09:27:33');
INSERT INTO `tb_snb_sys_codebase_folder` VALUES ('0242ac110007-11ed3a12-93b3ee0c-b656', 'R-特征选取(Feature Selection)', 0, '2022-09-22 09:27:33', '2022-09-22 09:27:33');
INSERT INTO `tb_snb_sys_codebase_folder` VALUES ('0242ac110007-11ed3a12-93b41512-b656', 'R-降低维度', 0, '2022-09-22 09:27:33', '2022-09-22 09:27:33');
INSERT INTO `tb_snb_sys_codebase_folder` VALUES ('0242ac110007-11ed3a12-93b42548-b656', 'R-数据清洗', 0, '2022-09-22 09:27:33', '2022-09-22 09:27:33');
INSERT INTO `tb_snb_sys_codebase_folder` VALUES ('0242ac110007-11ed3a12-93b45946-b656', 'R-String处理(stringr)', 0, '2022-09-22 09:27:33', '2022-09-22 09:27:33');
INSERT INTO `tb_snb_sys_codebase_folder` VALUES ('0242ac110007-11ed3a12-93b47dea-b656', '模型服务', 1, '2022-09-22 09:27:33', '2022-09-22 09:27:33');
INSERT INTO `tb_snb_sys_codebase_folder` VALUES ('0242ac110007-11ed3a12-93b49668-b656', 'SQL 操作', 1, '2022-09-22 09:27:33', '2022-09-22 09:27:33');
INSERT INTO `tb_snb_sys_codebase_folder` VALUES ('0242ac110007-11ed3a12-93b49c8a-b656', 'R-SQL操作', 0, '2022-09-22 09:27:33', '2022-09-22 09:27:33');
INSERT INTO `tb_snb_sys_codebase_folder` VALUES ('0242ac110007-11ed3a12-93b4d808-b656', '基本操作', 1, '2022-09-22 09:27:33', '2022-09-22 09:27:33');
INSERT INTO `tb_snb_sys_codebase_folder` VALUES ('547fb106-697c-11ed-93ea-507b9df4d741', 'Pandas小抄', 1, '2022-11-11 17:12:26', '2022-11-25 17:12:26');
COMMIT;

-- ----------------------------
-- Table structure for tb_snb_sys_image
-- ----------------------------
DROP TABLE IF EXISTS `tb_snb_sys_image`;
CREATE TABLE `tb_snb_sys_image` (
  `uid` varchar(36) COLLATE utf8_bin NOT NULL COMMENT '环境容器的镜像（image)UID',
  `name` varchar(16) COLLATE utf8_bin DEFAULT NULL COMMENT '环境容器的镜像（image)中文名称',
  `repository` varchar(45) COLLATE utf8_bin DEFAULT NULL COMMENT '环境容器的镜像（image)名称 ：snb/node 、ghcr.io/iron-fish/ironfish',
  `ver` varchar(16) COLLATE utf8_bin DEFAULT NULL COMMENT '环境容器的镜像（image) 版本 Tag ',
  `status` int(2) DEFAULT NULL COMMENT '1 有效的，0 为无效，历史还有存量使用。',
  `create_time` datetime DEFAULT NULL,
  `update_time` datetime DEFAULT NULL,
  PRIMARY KEY (`uid`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin ROW_FORMAT=DYNAMIC COMMENT='SNB node镜像表';

-- ----------------------------
-- Records of tb_snb_sys_image
-- ----------------------------
BEGIN;
INSERT INTO `tb_snb_sys_image` VALUES ('507b9df4d741-11ed25b2-32bf9c31-b6c3', 'Python3.8基础版', 'snb/node', '202304101758', 1, '2022-08-27 10:48:09', '2022-08-27 10:48:09');
INSERT INTO `tb_snb_sys_image` VALUES ('507b9df4d741-11ed25b2-32bfc362-aa99', 'Python3.8机器学习版', 'snb/node', '202304101758', 1, '2022-08-27 10:49:18', '2022-08-27 10:49:18');
COMMIT;

-- ----------------------------
-- Table structure for tb_snb_sys_machine_config
-- ----------------------------
DROP TABLE IF EXISTS `tb_snb_sys_machine_config`;
CREATE TABLE `tb_snb_sys_machine_config` (
  `uid` varchar(36) COLLATE utf8_bin NOT NULL COMMENT '机器配置模板的UID',
  `name` varchar(16) COLLATE utf8_bin DEFAULT NULL COMMENT '机器配置名称',
  `cpu` varchar(16) COLLATE utf8_bin DEFAULT NULL COMMENT '容器cpu 配额，  m为单位，1000m 为一核。参见 {"cpu": "2000m", "memory": "2048Mi","ephemeral-storage": "2Gi"}',
  `mem` varchar(16) COLLATE utf8_bin DEFAULT NULL COMMENT '容器内存配额：参见 {"cpu": "2000m", "memory": "2048Mi","ephemeral-storage": "2Gi"}',
  `storage` varchar(16) COLLATE utf8_bin DEFAULT NULL COMMENT '容器存储 配额，参见 {"cpu": "2000m", "memory": "2048Mi","ephemeral-storage": "2Gi"}',
  `gpu` varchar(16) COLLATE utf8_bin DEFAULT NULL COMMENT '容器gpu 配额，参见 {"cpu": "2000m", "memory": "2048Mi","ephemeral-storage": "2Gi"}',
  `status` int(2) DEFAULT NULL COMMENT '1 有效的，0 为无效，历史还有存量使用。',
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  `update_time` datetime DEFAULT NULL COMMENT '修改时间',
  `band_width` int(11) DEFAULT NULL COMMENT '带宽',
  PRIMARY KEY (`uid`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin ROW_FORMAT=DYNAMIC COMMENT='机器配置模板';

-- ----------------------------
-- Records of tb_snb_sys_machine_config
-- ----------------------------
BEGIN;
INSERT INTO `tb_snb_sys_machine_config` VALUES ('507b9df4d741-11ed25b2-32bfc363-bf47', '基本型', '2000m', '2048Mi', '10Gi', '', 1, '2022-08-27 10:54:23', '2022-08-27 10:54:23', 10);
INSERT INTO `tb_snb_sys_machine_config` VALUES ('507b9df4d741-11ed25b2-32bfc364-b7d0', '增强型', '4000m', '4096Mi', '20Gi', '', 1, '2022-08-27 10:55:28', '2022-08-27 10:55:28', 20);
INSERT INTO `tb_snb_sys_machine_config` VALUES ('fa8a5eea-3cb9-11ee-8002-27750862e58c', '高配32', '4000m', '32768Mi', '20Gi', ' ', 1, NULL, NULL, 20);
COMMIT;

-- ----------------------------
-- Table structure for tb_snb_user
-- ----------------------------
DROP TABLE IF EXISTS `tb_snb_user`;
CREATE TABLE `tb_snb_user` (
  `uid` varchar(36) COLLATE utf8_bin NOT NULL COMMENT '用户UID，uuid1  snb_utils.snb_uuid.uuid1()',
  `login_email` varchar(64) COLLATE utf8_bin DEFAULT NULL,
  `login_pw` varchar(96) COLLATE utf8_bin DEFAULT NULL COMMENT '用户密码，sha256 hash 不可逆 保存,snb_utils.snb_security 生成',
  `user_name` varchar(64) COLLATE utf8_bin DEFAULT NULL COMMENT '用户名',
  `logo` varchar(255) COLLATE utf8_bin DEFAULT NULL COMMENT '头像logo',
  `status` int(11) DEFAULT '0' COMMENT '0  初始状态，1 有效状态，-1 无效状态，0 状态验证email成功变为1 ',
  `check_email_token` varchar(36) COLLATE utf8_bin DEFAULT NULL,
  `create_time` datetime DEFAULT NULL,
  `update_time` datetime DEFAULT NULL,
  `last_login_time` datetime DEFAULT NULL,
  `last_ws_uid` varchar(36) COLLATE utf8_bin DEFAULT NULL COMMENT '用户最后一次选择的workspace uuid',
  `grade` varchar(10) COLLATE utf8_bin DEFAULT 'basic' COMMENT '用户级别：\nbasic 基础班\npro 专业版\nent 企业版',
  PRIMARY KEY (`uid`) USING BTREE,
  UNIQUE KEY `login_email_UNIQUE` (`login_email`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin ROW_FORMAT=DYNAMIC;

-- ----------------------------
-- Records of tb_snb_user
-- ----------------------------
BEGIN;
INSERT INTO `tb_snb_user` VALUES ('0242ac11000a-11ed2a86-5db8b684-88c3', 'qiang.zhao@yeexun.com.cn', 'sha256$yFpSJQv6$06813321e927419b27329f8b608b5fa5573965f02962a6d5572d893dbb7dd8ac', '强', '0242ac11000a-11ed2a86-5db8b684-88c3.JPG', 1, '', '2022-09-02 14:13:53', '2022-12-20 17:36:50', '2023-09-07 18:09:02', '0242ac11000a-11ed2a86-6affee3e-88c3', 'ent');
INSERT INTO `tb_snb_user` VALUES ('0242ac11001b-11ed258b-1f2b1362-91bd', 'wrss01@126.com', 'sha256$VFJcCSpR$ed7627a9b609d0d752c3892fd897210decca4a04caa99849e3be4295a3bdaabe', 'wrss01', '0242ac11001b-11ed258b-1f2b1362-91bd.png', 1, '', '2022-08-26 15:05:10', '2023-02-07 23:04:22', '2023-09-07 18:18:53', '0242ac11001b-11ed258b-2697c2bc-91bd', 'ent');
COMMIT;

-- ----------------------------
-- Table structure for tb_snb_user_collection
-- ----------------------------
DROP TABLE IF EXISTS `tb_snb_user_collection`;
CREATE TABLE `tb_snb_user_collection` (
  `uid` varchar(36) COLLATE utf8_bin NOT NULL,
  `cate_id` varchar(36) COLLATE utf8_bin DEFAULT NULL COMMENT '分类ID',
  `collection_name` varchar(64) COLLATE utf8_bin DEFAULT NULL COMMENT '收藏名称',
  `collection_content` text COLLATE utf8_bin COMMENT '收藏内容',
  `create_time` datetime DEFAULT NULL,
  `update_time` datetime DEFAULT NULL,
  `user_uid` varchar(36) COLLATE utf8_bin DEFAULT NULL COMMENT '用户ID',
  PRIMARY KEY (`uid`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin ROW_FORMAT=DYNAMIC;

-- ----------------------------
-- Records of tb_snb_user_collection
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for tb_snb_user_collection_cate
-- ----------------------------
DROP TABLE IF EXISTS `tb_snb_user_collection_cate`;
CREATE TABLE `tb_snb_user_collection_cate` (
  `uid` varchar(36) COLLATE utf8_bin NOT NULL,
  `cate_name` varchar(64) COLLATE utf8_bin DEFAULT NULL COMMENT '分类名称',
  `create_time` datetime DEFAULT NULL,
  `update_time` datetime DEFAULT NULL,
  `user_uid` varchar(36) COLLATE utf8_bin DEFAULT NULL COMMENT '用户ID',
  PRIMARY KEY (`uid`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin ROW_FORMAT=DYNAMIC;

-- ----------------------------
-- Records of tb_snb_user_collection_cate
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for tb_snb_user_favo
-- ----------------------------
DROP TABLE IF EXISTS `tb_snb_user_favo`;
CREATE TABLE `tb_snb_user_favo` (
  `uid` varchar(36) NOT NULL,
  `user_uid` varchar(36) DEFAULT NULL,
  `ws_uid` varchar(36) DEFAULT NULL,
  `nb_uid` varchar(36) DEFAULT NULL,
  `create_time` datetime DEFAULT NULL,
  PRIMARY KEY (`uid`) USING BTREE,
  UNIQUE KEY `user_nb` (`user_uid`,`nb_uid`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='Favorites ，用户收藏夹';

-- ----------------------------
-- Records of tb_snb_user_favo
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for tb_snb_user_invitation_code
-- ----------------------------
DROP TABLE IF EXISTS `tb_snb_user_invitation_code`;
CREATE TABLE `tb_snb_user_invitation_code` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `code` varchar(8) COLLATE utf8mb4_bin DEFAULT NULL,
  `status` int(11) DEFAULT NULL COMMENT '1 已经使用  0 待使用   -1 待发放，发放修改为0',
  `email` varchar(64) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '使用人email\n',
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  `use_time` datetime DEFAULT NULL COMMENT '使用时间',
  `desc` varchar(45) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '备注 发放对象',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE KEY `code_UNIQUE` (`code`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=116 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=DYNAMIC COMMENT='邀请码';

-- ----------------------------
-- Records of tb_snb_user_invitation_code
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for tb_snb_user_recent_open
-- ----------------------------
DROP TABLE IF EXISTS `tb_snb_user_recent_open`;
CREATE TABLE `tb_snb_user_recent_open` (
  `uid` varchar(36) COLLATE utf8mb4_bin NOT NULL,
  `user_uid` varchar(36) COLLATE utf8mb4_bin DEFAULT NULL,
  `nb_uid` varchar(36) COLLATE utf8mb4_bin DEFAULT NULL,
  `nb_title` varchar(45) COLLATE utf8mb4_bin DEFAULT NULL,
  `ws_uid` varchar(36) COLLATE utf8mb4_bin DEFAULT NULL,
  `update_time` datetime DEFAULT NULL,
  PRIMARY KEY (`uid`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=DYNAMIC COMMENT='用户最近打开记录';

-- ----------------------------
-- Records of tb_snb_user_recent_open
-- ----------------------------
BEGIN;
INSERT INTO `tb_snb_user_recent_open` VALUES ('0242ac110005-11ee4d66-53a3678a-9070', '0242ac11001b-11ed258b-1f2b1362-91bd', '0242ac110005-11ee4d64-2f8cf7f0-9102', 'helloworld', '0242ac11001b-11ed258b-2697c2bc-91bd', '2023-09-07 18:20:34');
INSERT INTO `tb_snb_user_recent_open` VALUES ('0242ac110005-11ee4d66-c55fa92e-9102', '0242ac11000a-11ed2a86-5db8b684-88c3', '0242ac110005-11ee4d66-c4c509d2-9102', '测试', '0242ac11000a-11ed2a86-6affee3e-88c3', '2023-09-07 18:14:18');
COMMIT;

-- ----------------------------
-- Table structure for tb_snb_workspace
-- ----------------------------
DROP TABLE IF EXISTS `tb_snb_workspace`;
CREATE TABLE `tb_snb_workspace` (
  `uid` varchar(36) COLLATE utf8_bin NOT NULL COMMENT 'UUID1 生成主键，用snb_utils 包',
  `name` varchar(64) COLLATE utf8_bin DEFAULT NULL COMMENT '工作空间名称',
  `desc` varchar(256) COLLATE utf8_bin DEFAULT NULL COMMENT '描述',
  `owner_uid` varchar(36) COLLATE utf8_bin DEFAULT NULL COMMENT '所有者用户UID、创建者UID',
  `status` int(11) DEFAULT '1' COMMENT '状态 1 有效，-1 无效',
  `res_version` varchar(16) COLLATE utf8_bin DEFAULT 'Standard' COMMENT '功能、资源版本：Standard Pro Enterprise',
  `logo` varchar(64) COLLATE utf8_bin DEFAULT NULL,
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  `update_time` datetime DEFAULT NULL COMMENT '修改时间',
  `gitlab_url` varchar(64) COLLATE utf8_bin DEFAULT NULL,
  `gitlab_access_token` varchar(64) COLLATE utf8_bin DEFAULT NULL,
  `gitlab_project_id` varchar(64) COLLATE utf8_bin DEFAULT NULL,
  `git_type` int(2) DEFAULT '0' COMMENT 'git 类型： 0 没有配置git\\\\n1 gitlab\\\\n2 github\\\\n',
  `is_default` int(11) DEFAULT '0' COMMENT '是否默认的ws ，每个人一个默认ws，默认是1 ，是自动创建的，或是是home。 其他为0 ，自己创建的',
  `private_pem` varchar(1024) COLLATE utf8_bin DEFAULT NULL COMMENT 'RSA 私钥 PEM 内容',
  `public_pem` varchar(320) COLLATE utf8_bin DEFAULT NULL COMMENT 'RSA 公钥 PEM 内容',
  `tag` int(11) DEFAULT NULL COMMENT '0 是默认创建不可 删除，1 是手动创建可删除',
  `git_branch` varchar(64) COLLATE utf8_bin DEFAULT NULL,
  PRIMARY KEY (`uid`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin ROW_FORMAT=DYNAMIC COMMENT='工作空间';

-- ----------------------------
-- Records of tb_snb_workspace
-- ----------------------------
BEGIN;
INSERT INTO `tb_snb_workspace` VALUES ('0242ac11000a-11ed2a86-6affee3e-88c3', 'workspace', 'test52', '0242ac11000a-11ed2a86-5db8b684-88c3', 1, 'Standard', '0242ac11000a-11ed2a86-6affee3e-88c3.JPG', '2022-09-02 14:13:53', '2023-08-24 15:09:17', 'http://172.30.81.88:81/', 'oxV3TexSVcsXXF95c6Ai', '312', 1, 1, '-----BEGIN RSA PRIVATE KEY-----\nMIICWwIBAAKBgQCD+A6+YQmkOZ7uMye6PHguzh8JmtznTUDPeG4sgVIfq25uuAHM\nqxlnxXin3o+xPBNy/tGEGpF2H8jMMr8uivnB17ZXZtb0O5wz/JVpKJRr9ZoIdtZ1\nHI5zFD+R4yk7QyMRdbQ49Zikv40KVqruHAmlldl/dMiColtxS5NP4y/eNwIDAQAB\nAoGAFBmCOAbUOW9j6x20IvkLc6gwhqhP6ulo7Jsyvz6Ma9xoER70zzUOxS+zZRtQ\nbAsdXzoRCSYkGjH/GvLDtuqzMqs9v2Vs5nSGlpBt9CYlyuKeqNuEWpF27Tj4D/2e\n43bsZ+nGS+5C76IQ73C+wNktNrVRjxPHoZtu8Md7X1oYQ0ECQQC3riofmIre8RA7\nqNctHL7gAqZ5Rt7xlmWw5jwALUgOjcVyY7wWBLjG8hbdAs1JzTurx2k/swKwvCjy\njavYwoOhAkEAt+21u6x1Gx9GjmCtMyGuSahtAW/MmHGB7BmhG+Oz7jPZ2nqdxdCF\nE0FLDzd2dVulbWtWNrCr4lKRIbbxYVIS1wJAbjO4YiyLZScMrj6mmxJcEtqENs8m\ng5vQd0orRY/lY5X7mJ3uAufiVLp6rS85K8ZOvslthCJKwu6hQqVtLSfHAQJAIwcZ\nQhmQ385wAHN26LL0X0C9KbXh7/JF/PHQleAihy3Gwm3xmBejEEyx/77fR3Bhq9ny\nPE4fHeX9j78obxFTVwJAL6odvTCX2r9+CMkwJ0y9+fOVSDNwiqZaT0jJScjw5dTJ\nnFOZMKwYmUrIE5sDcHFjZSn/5P0Y9EDBMii6hmuWzg==\n-----END RSA PRIVATE KEY-----', '-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCD+A6+YQmkOZ7uMye6PHguzh8J\nmtznTUDPeG4sgVIfq25uuAHMqxlnxXin3o+xPBNy/tGEGpF2H8jMMr8uivnB17ZX\nZtb0O5wz/JVpKJRr9ZoIdtZ1HI5zFD+R4yk7QyMRdbQ49Zikv40KVqruHAmlldl/\ndMiColtxS5NP4y/eNwIDAQAB\n-----END PUBLIC KEY-----', 0, 'master');
INSERT INTO `tb_snb_workspace` VALUES ('0242ac11001b-11ed258b-2697c2bc-91bd', 'wrss-01', 'sss3', '0242ac11001b-11ed258b-1f2b1362-91bd', 1, NULL, '0242ac11001b-11ed258b-2697c2bc-91bd.jpg', '2022-08-26 15:05:10', '2023-08-03 15:16:09', 'http://172.30.81.241:8000/', 'f122122fkjCgJQByAkDK', '2', 1, 0, '-----BEGIN RSA PRIVATE KEY-----\nMIICWwIBAAKBgQCD+A6+YQmkOZ7uMye6PHguzh8JmtznTUDPeG4sgVIfq25uuAHM\nqxlnxXin3o+xPBNy/tGEGpF2H8jMMr8uivnB17ZXZtb0O5wz/JVpKJRr9ZoIdtZ1\nHI5zFD+R4yk7QyMRdbQ49Zikv40KVqruHAmlldl/dMiColtxS5NP4y/eNwIDAQAB\nAoGAFBmCOAbUOW9j6x20IvkLc6gwhqhP6ulo7Jsyvz6Ma9xoER70zzUOxS+zZRtQ\nbAsdXzoRCSYkGjH/GvLDtuqzMqs9v2Vs5nSGlpBt9CYlyuKeqNuEWpF27Tj4D/2e\n43bsZ+nGS+5C76IQ73C+wNktNrVRjxPHoZtu8Md7X1oYQ0ECQQC3riofmIre8RA7\nqNctHL7gAqZ5Rt7xlmWw5jwALUgOjcVyY7wWBLjG8hbdAs1JzTurx2k/swKwvCjy\njavYwoOhAkEAt+21u6x1Gx9GjmCtMyGuSahtAW/MmHGB7BmhG+Oz7jPZ2nqdxdCF\nE0FLDzd2dVulbWtWNrCr4lKRIbbxYVIS1wJAbjO4YiyLZScMrj6mmxJcEtqENs8m\ng5vQd0orRY/lY5X7mJ3uAufiVLp6rS85K8ZOvslthCJKwu6hQqVtLSfHAQJAIwcZ\nQhmQ385wAHN26LL0X0C9KbXh7/JF/PHQleAihy3Gwm3xmBejEEyx/77fR3Bhq9ny\nPE4fHeX9j78obxFTVwJAL6odvTCX2r9+CMkwJ0y9+fOVSDNwiqZaT0jJScjw5dTJ\nnFOZMKwYmUrIE5sDcHFjZSn/5P0Y9EDBMii6hmuWzg==\n-----END RSA PRIVATE KEY-----', '-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCD+A6+YQmkOZ7uMye6PHguzh8J\nmtznTUDPeG4sgVIfq25uuAHMqxlnxXin3o+xPBNy/tGEGpF2H8jMMr8uivnB17ZX\nZtb0O5wz/JVpKJRr9ZoIdtZ1HI5zFD+R4yk7QyMRdbQ49Zikv40KVqruHAmlldl/\ndMiColtxS5NP4y/eNwIDAQAB\n-----END PUBLIC KEY-----', 0, 'master');
COMMIT;

-- ----------------------------
-- Table structure for tb_snb_ws_aigc_chatgpt
-- ----------------------------
DROP TABLE IF EXISTS `tb_snb_ws_aigc_chatgpt`;
CREATE TABLE `tb_snb_ws_aigc_chatgpt` (
  `uid` varchar(36) NOT NULL COMMENT 'hui',
  `ws_uid` varchar(36) DEFAULT NULL COMMENT 'workspace uid',
  `nb_uid` varchar(36) DEFAULT NULL COMMENT 'nb_uid',
  `title` varchar(45) DEFAULT NULL COMMENT '标题，初始为nb 的title',
  `create_time` datetime DEFAULT NULL,
  `update_time` datetime DEFAULT NULL,
  `status` int(11) DEFAULT NULL COMMENT '1 有效  0 删除',
  `author_uid` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`uid`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='chatGPT 会话(conversation)的内容表';

-- ----------------------------
-- Records of tb_snb_ws_aigc_chatgpt
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for tb_snb_ws_datasource
-- ----------------------------
DROP TABLE IF EXISTS `tb_snb_ws_datasource`;
CREATE TABLE `tb_snb_ws_datasource` (
  `uid` varchar(36) COLLATE utf8_bin NOT NULL,
  `name` varchar(16) COLLATE utf8_bin DEFAULT NULL,
  `desc` varchar(128) COLLATE utf8_bin DEFAULT NULL,
  `ds_type` varchar(16) COLLATE utf8_bin DEFAULT NULL COMMENT '数据类型：postgresql 、greenplum 、mysql、oracle、hive、impala、 clickhouse 、sqlserver 、 spark 、presto\n\n\n',
  `ws_uid` varchar(36) COLLATE utf8_bin DEFAULT NULL COMMENT '工作空间 UID',
  `create_time` datetime DEFAULT NULL,
  `update_time` datetime DEFAULT NULL,
  `author_uid` varchar(36) COLLATE utf8_bin DEFAULT NULL,
  `ssh_enabled` int(1) DEFAULT NULL COMMENT '默认0 disabled  1 enabled',
  `ssh_host` varchar(45) COLLATE utf8_bin DEFAULT NULL,
  `ssh_port` int(11) DEFAULT NULL,
  `ssh_user` varchar(45) COLLATE utf8_bin DEFAULT NULL,
  `ssh_password` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `db_type` varchar(10) COLLATE utf8_bin DEFAULT NULL COMMENT '默认为rdb 目前两种类型：rdb、gdb',
  PRIMARY KEY (`uid`) USING BTREE,
  UNIQUE KEY `name_uni` (`ws_uid`,`name`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin ROW_FORMAT=DYNAMIC COMMENT='数据源';

-- ----------------------------
-- Records of tb_snb_ws_datasource
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for tb_snb_ws_ds_clickhouse
-- ----------------------------
DROP TABLE IF EXISTS `tb_snb_ws_ds_clickhouse`;
CREATE TABLE `tb_snb_ws_ds_clickhouse` (
  `ds_uid` varchar(36) COLLATE utf8_bin NOT NULL,
  `ds_type` varchar(16) COLLATE utf8_bin DEFAULT NULL COMMENT '数据类型：clickhouse',
  `ws_uid` varchar(36) COLLATE utf8_bin DEFAULT NULL,
  `db_host` varchar(45) COLLATE utf8_bin DEFAULT NULL,
  `db_port` int(11) DEFAULT NULL,
  `db_user` varchar(45) COLLATE utf8_bin DEFAULT NULL,
  `db_database` varchar(64) COLLATE utf8_bin DEFAULT NULL,
  `db_password` varchar(256) COLLATE utf8_bin DEFAULT NULL COMMENT 'AES密码加密，加密参照snb_security  AES256$6096c65a20e2679064b3db3982c420a64efb1a485a499e793a3df0149185bc7b$87daaca9c46e98024484410112d98024',
  PRIMARY KEY (`ds_uid`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin ROW_FORMAT=DYNAMIC COMMENT='clickhouse 链接配置，继承tb_snb_ws_datasource';

-- ----------------------------
-- Records of tb_snb_ws_ds_clickhouse
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for tb_snb_ws_ds_duckdb
-- ----------------------------
DROP TABLE IF EXISTS `tb_snb_ws_ds_duckdb`;
CREATE TABLE `tb_snb_ws_ds_duckdb` (
  `ds_uid` varchar(36) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `ds_type` varchar(16) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL COMMENT '数据类型：mysql、oracle、hive、impala......',
  `ws_uid` varchar(36) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
  `db_user` varchar(45) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
  `db_database` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
  `db_password` varchar(256) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL COMMENT 'AES密码加密，加密参照snb_security  AES256$6096c65a20e2679064b3db3982c420a64efb1a485a499e793a3df0149185bc7b$87daaca9c46e98024484410112d98024',
  `authorization` varchar(45) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT 'user&password' COMMENT 'noAuth , user&password',
  `file_name` varchar(45) DEFAULT NULL COMMENT '文件名称\n',
  PRIMARY KEY (`ds_uid`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;

-- ----------------------------
-- Records of tb_snb_ws_ds_duckdb
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for tb_snb_ws_ds_greenplum
-- ----------------------------
DROP TABLE IF EXISTS `tb_snb_ws_ds_greenplum`;
CREATE TABLE `tb_snb_ws_ds_greenplum` (
  `ds_uid` varchar(36) COLLATE utf8_bin NOT NULL,
  `ds_type` varchar(16) COLLATE utf8_bin DEFAULT NULL COMMENT '数据类型：greenplum',
  `ws_uid` varchar(36) COLLATE utf8_bin DEFAULT NULL,
  `db_host` varchar(45) COLLATE utf8_bin DEFAULT NULL,
  `db_port` int(11) DEFAULT NULL,
  `db_user` varchar(45) COLLATE utf8_bin DEFAULT NULL,
  `db_database` varchar(64) COLLATE utf8_bin DEFAULT NULL,
  `db_password` varchar(256) COLLATE utf8_bin DEFAULT NULL COMMENT 'AES密码加密，加密参照snb_security  AES256$6096c65a20e2679064b3db3982c420a64efb1a485a499e793a3df0149185bc7b$87daaca9c46e98024484410112d98024',
  PRIMARY KEY (`ds_uid`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin ROW_FORMAT=DYNAMIC COMMENT='greenplum 链接配置，继承tb_snb_ws_datasource';

-- ----------------------------
-- Records of tb_snb_ws_ds_greenplum
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for tb_snb_ws_ds_hive
-- ----------------------------
DROP TABLE IF EXISTS `tb_snb_ws_ds_hive`;
CREATE TABLE `tb_snb_ws_ds_hive` (
  `ds_uid` varchar(36) COLLATE utf8_bin NOT NULL,
  `ds_type` varchar(16) COLLATE utf8_bin DEFAULT NULL COMMENT '数据类型：hive',
  `ws_uid` varchar(36) COLLATE utf8_bin DEFAULT NULL,
  `db_host` varchar(45) COLLATE utf8_bin DEFAULT NULL,
  `db_port` int(11) DEFAULT NULL,
  `db_user` varchar(45) COLLATE utf8_bin DEFAULT NULL,
  `db_database` varchar(64) COLLATE utf8_bin DEFAULT NULL,
  `db_password` varchar(256) COLLATE utf8_bin DEFAULT NULL COMMENT 'AES密码加密，加密参照snb_security  AES256$6096c65a20e2679064b3db3982c420a64efb1a485a499e793a3df0149185bc7b$87daaca9c46e98024484410112d98024',
  `authorization` varchar(45) COLLATE utf8_bin DEFAULT 'user&password' COMMENT 'noAuth , user&password',
  PRIMARY KEY (`ds_uid`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin ROW_FORMAT=DYNAMIC COMMENT='hive 链接配置，继承tb_snb_ws_datasource';

-- ----------------------------
-- Records of tb_snb_ws_ds_hive
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for tb_snb_ws_ds_mindsdb
-- ----------------------------
DROP TABLE IF EXISTS `tb_snb_ws_ds_mindsdb`;
CREATE TABLE `tb_snb_ws_ds_mindsdb` (
  `ds_uid` varchar(36) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `ds_type` varchar(16) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL COMMENT '数据类型：mysql、oracle、hive、impala......',
  `ws_uid` varchar(36) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
  `db_host` varchar(45) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
  `db_port` int(11) DEFAULT NULL,
  `db_user` varchar(45) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
  `db_database` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
  `db_password` varchar(256) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL COMMENT 'AES密码加密，加密参照snb_security  AES256$6096c65a20e2679064b3db3982c420a64efb1a485a499e793a3df0149185bc7b$87daaca9c46e98024484410112d98024',
  PRIMARY KEY (`ds_uid`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;

-- ----------------------------
-- Records of tb_snb_ws_ds_mindsdb
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for tb_snb_ws_ds_mysql
-- ----------------------------
DROP TABLE IF EXISTS `tb_snb_ws_ds_mysql`;
CREATE TABLE `tb_snb_ws_ds_mysql` (
  `ds_uid` varchar(36) COLLATE utf8_bin NOT NULL,
  `ds_type` varchar(16) COLLATE utf8_bin DEFAULT NULL COMMENT '数据类型：mysql、oracle、hive、impala......',
  `ws_uid` varchar(36) COLLATE utf8_bin DEFAULT NULL,
  `db_host` varchar(45) COLLATE utf8_bin DEFAULT NULL,
  `db_port` int(11) DEFAULT NULL,
  `db_user` varchar(45) COLLATE utf8_bin DEFAULT NULL,
  `db_database` varchar(64) COLLATE utf8_bin DEFAULT NULL,
  `db_password` varchar(256) COLLATE utf8_bin DEFAULT NULL COMMENT 'AES密码加密，加密参照snb_security  AES256$6096c65a20e2679064b3db3982c420a64efb1a485a499e793a3df0149185bc7b$87daaca9c46e98024484410112d98024',
  PRIMARY KEY (`ds_uid`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin ROW_FORMAT=DYNAMIC COMMENT='MySQL 链接配置，继承tb_snb_ws_datasource';

-- ----------------------------
-- Records of tb_snb_ws_ds_mysql
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for tb_snb_ws_ds_neo4j
-- ----------------------------
DROP TABLE IF EXISTS `tb_snb_ws_ds_neo4j`;
CREATE TABLE `tb_snb_ws_ds_neo4j` (
  `ds_uid` varchar(36) COLLATE utf8_bin NOT NULL,
  `ds_type` varchar(16) COLLATE utf8_bin DEFAULT NULL COMMENT '数据类型：mysql、oracle、hive、impala......',
  `ws_uid` varchar(36) COLLATE utf8_bin DEFAULT NULL,
  `db_host` varchar(45) COLLATE utf8_bin DEFAULT NULL,
  `db_port` int(11) DEFAULT NULL,
  `db_user` varchar(45) COLLATE utf8_bin DEFAULT NULL,
  `db_database` varchar(64) COLLATE utf8_bin DEFAULT NULL,
  `db_password` varchar(256) COLLATE utf8_bin DEFAULT NULL COMMENT 'AES密码加密，加密参照snb_security  AES256$6096c65a20e2679064b3db3982c420a64efb1a485a499e793a3df0149185bc7b$87daaca9c46e98024484410112d98024',
  PRIMARY KEY (`ds_uid`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin ROW_FORMAT=DYNAMIC COMMENT='MySQL 链接配置，继承tb_snb_ws_datasource';

-- ----------------------------
-- Records of tb_snb_ws_ds_neo4j
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for tb_snb_ws_ds_oracle
-- ----------------------------
DROP TABLE IF EXISTS `tb_snb_ws_ds_oracle`;
CREATE TABLE `tb_snb_ws_ds_oracle` (
  `ds_uid` varchar(36) COLLATE utf8_bin NOT NULL,
  `ds_type` varchar(16) COLLATE utf8_bin DEFAULT NULL COMMENT '数据类型：oracle',
  `ws_uid` varchar(36) COLLATE utf8_bin DEFAULT NULL,
  `db_host` varchar(45) COLLATE utf8_bin DEFAULT NULL,
  `db_port` int(11) DEFAULT NULL,
  `db_user` varchar(45) COLLATE utf8_bin DEFAULT NULL,
  `db_sid` varchar(45) COLLATE utf8_bin DEFAULT NULL,
  `db_driver` varchar(45) COLLATE utf8_bin DEFAULT NULL COMMENT '驱动类型',
  `db_password` varchar(256) COLLATE utf8_bin DEFAULT NULL COMMENT 'AES密码加密，加密参照snb_security  AES256$6096c65a20e2679064b3db3982c420a64efb1a485a499e793a3df0149185bc7b$87daaca9c46e98024484410112d98024',
  PRIMARY KEY (`ds_uid`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin ROW_FORMAT=DYNAMIC COMMENT='oracle 链接配置，继承tb_snb_ws_datasource';

-- ----------------------------
-- Records of tb_snb_ws_ds_oracle
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for tb_snb_ws_ds_postgresql
-- ----------------------------
DROP TABLE IF EXISTS `tb_snb_ws_ds_postgresql`;
CREATE TABLE `tb_snb_ws_ds_postgresql` (
  `ds_uid` varchar(36) COLLATE utf8_bin NOT NULL,
  `ds_type` varchar(16) COLLATE utf8_bin DEFAULT NULL COMMENT '数据类型：postgresql',
  `ws_uid` varchar(36) COLLATE utf8_bin DEFAULT NULL,
  `db_host` varchar(45) COLLATE utf8_bin DEFAULT NULL,
  `db_port` int(11) DEFAULT NULL,
  `db_user` varchar(45) COLLATE utf8_bin DEFAULT NULL,
  `db_database` varchar(64) COLLATE utf8_bin DEFAULT NULL,
  `db_password` varchar(256) COLLATE utf8_bin DEFAULT NULL COMMENT 'AES密码加密，加密参照snb_security  AES256$6096c65a20e2679064b3db3982c420a64efb1a485a499e793a3df0149185bc7b$87daaca9c46e98024484410112d98024',
  PRIMARY KEY (`ds_uid`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin ROW_FORMAT=DYNAMIC COMMENT='hive 链接配置，继承tb_snb_ws_datasource';

-- ----------------------------
-- Records of tb_snb_ws_ds_postgresql
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for tb_snb_ws_ds_presto
-- ----------------------------
DROP TABLE IF EXISTS `tb_snb_ws_ds_presto`;
CREATE TABLE `tb_snb_ws_ds_presto` (
  `ds_uid` varchar(36) COLLATE utf8_bin NOT NULL,
  `ds_type` varchar(16) COLLATE utf8_bin DEFAULT NULL COMMENT '数据类型：presto',
  `ws_uid` varchar(36) COLLATE utf8_bin DEFAULT NULL,
  `db_host` varchar(45) COLLATE utf8_bin DEFAULT NULL,
  `db_port` int(11) DEFAULT NULL,
  `db_user` varchar(45) COLLATE utf8_bin DEFAULT NULL,
  `db_database` varchar(64) COLLATE utf8_bin DEFAULT NULL,
  `db_password` varchar(256) COLLATE utf8_bin DEFAULT NULL COMMENT 'AES密码加密，加密参照snb_security  AES256$6096c65a20e2679064b3db3982c420a64efb1a485a499e793a3df0149185bc7b$87daaca9c46e98024484410112d98024',
  `authorization` varchar(45) COLLATE utf8_bin DEFAULT 'user&password' COMMENT 'noAuth , user&password',
  PRIMARY KEY (`ds_uid`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin ROW_FORMAT=DYNAMIC COMMENT='presto 链接配置，继承tb_snb_ws_datasource';

-- ----------------------------
-- Records of tb_snb_ws_ds_presto
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for tb_snb_ws_ds_spark
-- ----------------------------
DROP TABLE IF EXISTS `tb_snb_ws_ds_spark`;
CREATE TABLE `tb_snb_ws_ds_spark` (
  `ds_uid` varchar(36) COLLATE utf8_bin NOT NULL,
  `ds_type` varchar(16) COLLATE utf8_bin DEFAULT NULL COMMENT '数据类型：spark',
  `ws_uid` varchar(36) COLLATE utf8_bin DEFAULT NULL,
  `db_host` varchar(45) COLLATE utf8_bin DEFAULT NULL,
  `db_port` int(11) DEFAULT NULL,
  `db_user` varchar(45) COLLATE utf8_bin DEFAULT NULL,
  `db_database` varchar(64) COLLATE utf8_bin DEFAULT NULL,
  `db_password` varchar(256) COLLATE utf8_bin DEFAULT NULL COMMENT 'AES密码加密，加密参照snb_security  AES256$6096c65a20e2679064b3db3982c420a64efb1a485a499e793a3df0149185bc7b$87daaca9c46e98024484410112d98024',
  `authorization` varchar(45) COLLATE utf8_bin DEFAULT 'user&password' COMMENT 'noAuth , user&password',
  PRIMARY KEY (`ds_uid`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin ROW_FORMAT=DYNAMIC COMMENT='spark 链接配置，继承tb_snb_ws_datasource';

-- ----------------------------
-- Records of tb_snb_ws_ds_spark
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for tb_snb_ws_ds_sqlserver
-- ----------------------------
DROP TABLE IF EXISTS `tb_snb_ws_ds_sqlserver`;
CREATE TABLE `tb_snb_ws_ds_sqlserver` (
  `ds_uid` varchar(36) COLLATE utf8_bin NOT NULL,
  `ds_type` varchar(16) COLLATE utf8_bin DEFAULT NULL COMMENT '数据类型：sqlserver',
  `ws_uid` varchar(36) COLLATE utf8_bin DEFAULT NULL,
  `db_host` varchar(45) COLLATE utf8_bin DEFAULT NULL,
  `db_port` int(11) DEFAULT NULL,
  `db_instance` varchar(45) COLLATE utf8_bin DEFAULT NULL,
  `db_user` varchar(45) COLLATE utf8_bin DEFAULT NULL,
  `db_database` varchar(45) COLLATE utf8_bin DEFAULT NULL,
  `db_password` varchar(256) COLLATE utf8_bin DEFAULT NULL COMMENT 'AES密码加密，加密参照snb_security  AES256$6096c65a20e2679064b3db3982c420a64efb1a485a499e793a3df0149185bc7b$87daaca9c46e98024484410112d98024',
  PRIMARY KEY (`ds_uid`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin ROW_FORMAT=DYNAMIC COMMENT='sqlserver 链接配置，继承tb_snb_ws_datasource';

-- ----------------------------
-- Records of tb_snb_ws_ds_sqlserver
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for tb_snb_ws_environment
-- ----------------------------
DROP TABLE IF EXISTS `tb_snb_ws_environment`;
CREATE TABLE `tb_snb_ws_environment` (
  `uid` varchar(36) COLLATE utf8_bin NOT NULL COMMENT '环境UID，即用户开发kernel 环境，或用户对应snb_node 环境，python kernel 执行环境，',
  `ws_uid` varchar(36) COLLATE utf8_bin DEFAULT NULL COMMENT '所属workspace 的UID，一个workspace 可以有多套环境（计算资源）',
  `name` varchar(64) COLLATE utf8_bin DEFAULT NULL COMMENT '环境的名称',
  `status` varchar(16) COLLATE utf8_bin DEFAULT NULL COMMENT '环境的状态，0 新建，1 创建成功，2 存在问题待修复，-1 删除待回收',
  `img_uid` varchar(36) COLLATE utf8_bin DEFAULT NULL COMMENT '环境容器的镜像（image)UID',
  `img_name` varchar(16) COLLATE utf8_bin DEFAULT NULL COMMENT '环境容器的镜像（image)中文名称',
  `img_repository` varchar(32) COLLATE utf8_bin DEFAULT NULL COMMENT '环境容器的镜像（image)名称 ：snb/node 、ghcr.io/iron-fish/ironfish',
  `img_ver` varchar(16) COLLATE utf8_bin DEFAULT NULL COMMENT '环境容器的镜像（image) 版本 Tag ',
  `mc_uid` varchar(36) COLLATE utf8_bin DEFAULT NULL COMMENT '机器配置模板的UID',
  `mc_name` varchar(16) COLLATE utf8_bin DEFAULT NULL COMMENT '机器配置名称',
  `mc_cpu` varchar(16) COLLATE utf8_bin DEFAULT NULL COMMENT '容器cpu 配额，  m为单位，1000m 为一核。参见 {"cpu": "2000m", "memory": "2048Mi","ephemeral-storage": "2Gi"}',
  `mc_mem` varchar(16) COLLATE utf8_bin DEFAULT NULL COMMENT '容器内存配额：参见 {"cpu": "2000m", "memory": "2048Mi","ephemeral-storage": "2Gi"}',
  `mc_storage` varchar(16) COLLATE utf8_bin DEFAULT NULL COMMENT '容器存储 配额，参见 {"cpu": "2000m", "memory": "2048Mi","ephemeral-storage": "2Gi"}',
  `mc_gpu` varchar(16) COLLATE utf8_bin DEFAULT NULL COMMENT '容器gpu 配额，参见 {"cpu": "2000m", "memory": "2048Mi","ephemeral-storage": "2Gi"}',
  `mc_band_width` int(11) DEFAULT NULL COMMENT '容器带宽配额',
  `cntr_id` varchar(36) COLLATE utf8_bin DEFAULT NULL COMMENT '容器ID',
  `cntr_name` varchar(128) COLLATE utf8_bin DEFAULT NULL COMMENT '容器名称',
  `cntr_node_hostname` varchar(16) COLLATE utf8_bin DEFAULT NULL COMMENT '所在节点的机器名称',
  `cntr_node_ip` varchar(16) COLLATE utf8_bin DEFAULT NULL COMMENT '所在节点的ip地址',
  `cntr_node_port` varchar(16) COLLATE utf8_bin DEFAULT NULL COMMENT 'snb_node 的端口',
  `cntr_status` varchar(45) COLLATE utf8_bin DEFAULT NULL COMMENT '容器状态：Exited 、UP',
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  `update_time` datetime DEFAULT NULL COMMENT '修改时间',
  `used_runtime` int(11) DEFAULT NULL COMMENT '已运行时长 单位小时',
  `total_runtime` int(11) DEFAULT NULL COMMENT '总时长 单位:小时',
  `is_default` int(1) DEFAULT NULL COMMENT '0  是其他，1 是ws 默认环境',
  PRIMARY KEY (`uid`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin ROW_FORMAT=DYNAMIC COMMENT='环境,snb note 的容器信息表';

-- ----------------------------
-- Records of tb_snb_ws_environment
-- ----------------------------
BEGIN;
INSERT INTO `tb_snb_ws_environment` VALUES ('0242ac110007-11ed2cbc-11200302-1234', '0242ac11001b-11ed258b-2697c2bc-91bd', '测试', '1', '507b9df4d741-11ed25b2-32bf9c31-b6c3', 'Python3.8基础版', 'snb/node', 'v3', '507b9df4d741-11ed25b2-32bfc363-bf47', '基本型', '2000m', '2048Mi', '10Gi', '', 10, 'mount', 'mount', 'mount', '10.152.206.199', '8000', '1', '2022-09-05 09:44:39', '2023-02-16 02:00:15', 0, 720, 1);
INSERT INTO `tb_snb_ws_environment` VALUES ('0242ac110007-11ed2cbc-11200302-90c7', '0242ac11000a-11ed2a86-6affee3e-88c3', '测试', '1', '507b9df4d741-11ed25b2-32bf9c31-b6c3', 'Python3.8基础版', 'snb/node', 'v3', '507b9df4d741-11ed25b2-32bfc363-bf47', '基本型', '2000m', '2048Mi', '10Gi', '', 10, 'mount', 'mount', 'mount', '10.152.206.199', '8000', '1', '2022-09-05 09:44:39', '2023-02-16 02:00:15', 0, 720, 1);
COMMIT;

-- ----------------------------
-- Table structure for tb_snb_ws_file
-- ----------------------------
DROP TABLE IF EXISTS `tb_snb_ws_file`;
CREATE TABLE `tb_snb_ws_file` (
  `uid` varchar(36) COLLATE utf8_bin NOT NULL,
  `name` varchar(45) COLLATE utf8_bin DEFAULT NULL COMMENT '文件名',
  `folder_uid` varchar(36) COLLATE utf8_bin DEFAULT NULL COMMENT '目录UID',
  `ws_uid` varchar(36) COLLATE utf8_bin DEFAULT NULL COMMENT '工作空间UID',
  `size` bigint(10) DEFAULT NULL,
  `path` varchar(45) COLLATE utf8_bin DEFAULT NULL COMMENT '文件存储路径，物理路径',
  `author_uid` varchar(36) COLLATE utf8_bin DEFAULT NULL,
  `create_time` datetime DEFAULT NULL,
  `update_time` datetime DEFAULT NULL,
  `file_path` varchar(128) COLLATE utf8_bin DEFAULT '/home/',
  PRIMARY KEY (`uid`) USING BTREE,
  UNIQUE KEY `name_uni` (`ws_uid`,`folder_uid`,`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='资源文件';

-- ----------------------------
-- Records of tb_snb_ws_file
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for tb_snb_ws_file_folder
-- ----------------------------
DROP TABLE IF EXISTS `tb_snb_ws_file_folder`;
CREATE TABLE `tb_snb_ws_file_folder` (
  `uid` varchar(36) COLLATE utf8_bin NOT NULL,
  `name` varchar(64) COLLATE utf8_bin DEFAULT NULL COMMENT '目录名称',
  `parent_uid` varchar(36) COLLATE utf8_bin DEFAULT NULL COMMENT '上一级目录',
  `ws_uid` varchar(36) COLLATE utf8_bin DEFAULT NULL COMMENT '工作空间 UID',
  `author_uid` varchar(36) COLLATE utf8_bin DEFAULT NULL,
  `create_time` datetime DEFAULT NULL,
  `update_time` datetime DEFAULT NULL,
  `file_path` varchar(128) COLLATE utf8_bin DEFAULT '/home/',
  PRIMARY KEY (`uid`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin ROW_FORMAT=DYNAMIC COMMENT='工作空间目录';

-- ----------------------------
-- Records of tb_snb_ws_file_folder
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for tb_snb_ws_nb_comment
-- ----------------------------
DROP TABLE IF EXISTS `tb_snb_ws_nb_comment`;
CREATE TABLE `tb_snb_ws_nb_comment` (
  `uid` varchar(36) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `ws_uid` varchar(36) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
  `nb_uid` varchar(36) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
  `user_uid` varchar(36) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
  `cell_uid` varchar(45) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
  `content` text,
  `create_time` datetime DEFAULT NULL,
  `update_time` datetime DEFAULT NULL,
  PRIMARY KEY (`uid`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='comment 单元格注释';

-- ----------------------------
-- Records of tb_snb_ws_nb_comment
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for tb_snb_ws_nb_folder
-- ----------------------------
DROP TABLE IF EXISTS `tb_snb_ws_nb_folder`;
CREATE TABLE `tb_snb_ws_nb_folder` (
  `uid` varchar(36) COLLATE utf8_bin NOT NULL,
  `name` varchar(64) COLLATE utf8_bin DEFAULT NULL COMMENT '目录名称',
  `parent_uid` varchar(36) COLLATE utf8_bin DEFAULT NULL COMMENT '上一级目录',
  `ws_uid` varchar(36) COLLATE utf8_bin DEFAULT NULL COMMENT '工作空间 UID',
  `author_uid` varchar(36) COLLATE utf8_bin DEFAULT NULL,
  `create_time` datetime DEFAULT NULL,
  `update_time` datetime DEFAULT NULL,
  `file_path` varchar(256) COLLATE utf8_bin DEFAULT NULL COMMENT '路径',
  PRIMARY KEY (`uid`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin ROW_FORMAT=DYNAMIC COMMENT='工作空间Notebook目录';

-- ----------------------------
-- Records of tb_snb_ws_nb_folder
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for tb_snb_ws_nb_recycle
-- ----------------------------
DROP TABLE IF EXISTS `tb_snb_ws_nb_recycle`;
CREATE TABLE `tb_snb_ws_nb_recycle` (
  `uid` varchar(36) COLLATE utf8_bin NOT NULL,
  `folder_uid` varchar(36) COLLATE utf8_bin DEFAULT NULL,
  `ws_uid` varchar(36) COLLATE utf8_bin DEFAULT NULL,
  `author_uid` varchar(36) COLLATE utf8_bin DEFAULT NULL,
  `title` varchar(64) COLLATE utf8_bin DEFAULT NULL,
  `desc` varchar(128) COLLATE utf8_bin DEFAULT NULL,
  `create_time` datetime DEFAULT NULL,
  `update_time` datetime DEFAULT NULL,
  `kernel_type` varchar(16) COLLATE utf8_bin DEFAULT NULL,
  `computation_mode` varchar(16) COLLATE utf8_bin DEFAULT NULL COMMENT '默认为nb_mode(标准模式)',
  `envir_uid` varchar(36) COLLATE utf8_bin DEFAULT NULL,
  `recy_time` datetime DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`uid`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin ROW_FORMAT=DYNAMIC COMMENT='Notebook 回收站';

-- ----------------------------
-- Records of tb_snb_ws_nb_recycle
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for tb_snb_ws_nb_version
-- ----------------------------
DROP TABLE IF EXISTS `tb_snb_ws_nb_version`;
CREATE TABLE `tb_snb_ws_nb_version` (
  `uid` varchar(36) COLLATE utf8_bin NOT NULL,
  `ws_uid` varchar(36) COLLATE utf8_bin DEFAULT NULL,
  `nb_uid` varchar(36) COLLATE utf8_bin DEFAULT NULL,
  `user_uid` varchar(36) COLLATE utf8_bin DEFAULT NULL COMMENT 'commit 用户ID',
  `ver_name` varchar(45) COLLATE utf8_bin DEFAULT NULL COMMENT '版本名称，不会git 生成tag 或分支，只是对应一次commit 而已。',
  `commit_msg` varchar(128) COLLATE utf8_bin DEFAULT NULL COMMENT 'ver_name 和commit_msg ,组合一起为git commit message。',
  `create_time` datetime DEFAULT NULL,
  `update_time` datetime DEFAULT NULL,
  `user_email` varchar(128) COLLATE utf8_bin DEFAULT NULL COMMENT '所属邮箱',
  `is_push` int(1) DEFAULT NULL COMMENT '是否推送',
  PRIMARY KEY (`uid`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin ROW_FORMAT=DYNAMIC COMMENT='notebook 版本';

-- ----------------------------
-- Records of tb_snb_ws_nb_version
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for tb_snb_ws_notebook
-- ----------------------------
DROP TABLE IF EXISTS `tb_snb_ws_notebook`;
CREATE TABLE `tb_snb_ws_notebook` (
  `uid` varchar(36) COLLATE utf8_bin NOT NULL,
  `folder_uid` varchar(36) COLLATE utf8_bin DEFAULT NULL,
  `ws_uid` varchar(36) COLLATE utf8_bin DEFAULT NULL,
  `author_uid` varchar(36) COLLATE utf8_bin DEFAULT NULL,
  `title` varchar(64) COLLATE utf8_bin DEFAULT NULL,
  `desc` varchar(128) COLLATE utf8_bin DEFAULT NULL,
  `create_time` datetime DEFAULT NULL,
  `update_time` datetime DEFAULT NULL,
  `kernel_type` varchar(16) COLLATE utf8_bin NOT NULL COMMENT 'ir  、 python3、sagemath、julia-1.6',
  `computation_mode` varchar(16) COLLATE utf8_bin DEFAULT NULL COMMENT '默认为nb_mode(标准模式)',
  `envir_uid` varchar(36) COLLATE utf8_bin DEFAULT NULL,
  `status` int(11) DEFAULT '1' COMMENT '1、                2、             3、              4、               5\n Exploratory, Approved,  In Progress, Production , Archive\n探索、         批准、        进行中、    制作、         存档',
  `scheduler` int(11) DEFAULT '0' COMMENT '是否配置 0 1 ',
  PRIMARY KEY (`uid`) USING BTREE,
  UNIQUE KEY `title_uni` (`ws_uid`,`folder_uid`,`title`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin ROW_FORMAT=DYNAMIC COMMENT='Notebook';

-- ----------------------------
-- Records of tb_snb_ws_notebook
-- ----------------------------
BEGIN;
INSERT INTO `tb_snb_ws_notebook` VALUES ('0242ac110005-11ee4d64-2f8cf7f0-9102', '', '0242ac11001b-11ed258b-2697c2bc-91bd', '0242ac11001b-11ed258b-1f2b1362-91bd', 'helloworld', NULL, '2023-09-07 17:51:58', '2023-09-07 18:21:04', 'python3', 'nb_mode', '0242ac110007-11ed2cbc-11200302-1234', 1, 0);
INSERT INTO `tb_snb_ws_notebook` VALUES ('0242ac110005-11ee4d66-c4c509d2-9102', '', '0242ac11000a-11ed2a86-6affee3e-88c3', '0242ac11000a-11ed2a86-5db8b684-88c3', '测试', NULL, '2023-09-07 18:10:28', '2023-09-07 18:14:48', 'python3', 'nb_mode', '0242ac110004-11ed3ef5-ba5b80c8-b8ed', 1, 0);
COMMIT;

-- ----------------------------
-- Table structure for tb_snb_ws_report
-- ----------------------------
DROP TABLE IF EXISTS `tb_snb_ws_report`;
CREATE TABLE `tb_snb_ws_report` (
  `uid` varchar(36) COLLATE utf8_bin NOT NULL COMMENT '执行记录',
  `ws_uid` varchar(36) COLLATE utf8_bin DEFAULT NULL COMMENT 'WS_UID',
  `nb_uid` varchar(36) COLLATE utf8_bin DEFAULT NULL COMMENT 'NB_uid',
  `name` varchar(64) COLLATE utf8_bin DEFAULT NULL COMMENT '报告名称，从NB 继承',
  `status` int(11) DEFAULT NULL COMMENT '状态： 1是成功，0 失败\n',
  `start_time` datetime DEFAULT NULL COMMENT '执行开始时间',
  `end_time` datetime DEFAULT NULL COMMENT '执行结束时间',
  `create_time` datetime DEFAULT NULL COMMENT '记录生成时间',
  `envir_uid` varchar(36) COLLATE utf8_bin DEFAULT NULL COMMENT '环境ID',
  PRIMARY KEY (`uid`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin ROW_FORMAT=DYNAMIC COMMENT='snb 报告文件\nSNB 执行的结果文件记录';

-- ----------------------------
-- Records of tb_snb_ws_report
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for tb_snb_ws_secrets
-- ----------------------------
DROP TABLE IF EXISTS `tb_snb_ws_secrets`;
CREATE TABLE `tb_snb_ws_secrets` (
  `uid` varchar(36) COLLATE utf8mb4_bin NOT NULL,
  `ws_uid` varchar(36) COLLATE utf8mb4_bin DEFAULT NULL COMMENT 'workspace_uid',
  `name` varchar(64) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '变量名称',
  `value` varchar(256) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '变量值',
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  `update_time` datetime DEFAULT NULL COMMENT '修改时间',
  `encrypt` varchar(2) COLLATE utf8mb4_bin DEFAULT 'N' COMMENT 'encrypt 加密与否，默认是N 不加密，Y 加密，保存库里面进行加密',
  `author_uid` varchar(36) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
  PRIMARY KEY (`uid`) USING BTREE,
  UNIQUE KEY `name` (`uid`,`name`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=DYNAMIC COMMENT='密保箱，保持不宜公开配置变量，比如密码、tonken等信息';

-- ----------------------------
-- Records of tb_snb_ws_secrets
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for tb_snb_ws_share
-- ----------------------------
DROP TABLE IF EXISTS `tb_snb_ws_share`;
CREATE TABLE `tb_snb_ws_share` (
  `uid` bigint(20) NOT NULL AUTO_INCREMENT,
  `name` varchar(45) COLLATE utf8_bin DEFAULT NULL COMMENT '文件名',
  `ws_uid` varchar(36) COLLATE utf8_bin DEFAULT NULL COMMENT '工作空间UID',
  `cell_uid` varchar(36) COLLATE utf8_bin DEFAULT NULL COMMENT '单元格ID',
  `nb_uid` varchar(36) COLLATE utf8_bin DEFAULT NULL COMMENT 'nbUId',
  `path` varchar(45) COLLATE utf8_bin DEFAULT NULL COMMENT '文件存储路径，物理路径',
  `author_uid` varchar(36) COLLATE utf8_bin DEFAULT NULL COMMENT '创者',
  `create_time` datetime DEFAULT NULL COMMENT '添加时间',
  `update_time` datetime DEFAULT NULL COMMENT '更新时间',
  `content_type` int(10) DEFAULT NULL,
  `hash_uid` varchar(255) COLLATE utf8_bin DEFAULT NULL COMMENT '分享hash',
  PRIMARY KEY (`uid`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=271 DEFAULT CHARSET=utf8 COLLATE=utf8_bin ROW_FORMAT=DYNAMIC;

-- ----------------------------
-- Records of tb_snb_ws_share
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for tb_snb_ws_user
-- ----------------------------
DROP TABLE IF EXISTS `tb_snb_ws_user`;
CREATE TABLE `tb_snb_ws_user` (
  `uid` varchar(36) COLLATE utf8_bin NOT NULL COMMENT 'UID，uuid1 snbutils 生成',
  `ws_uid` varchar(36) COLLATE utf8_bin DEFAULT NULL,
  `user_uid` varchar(36) COLLATE utf8_bin DEFAULT NULL,
  `role` varchar(16) COLLATE utf8_bin DEFAULT NULL COMMENT '角色:Admin、Editor、Viewer',
  `status` int(11) DEFAULT NULL COMMENT '0 邀请，1 加入正常状态，  -1 无效状态',
  `create_time` datetime DEFAULT NULL,
  `update_time` datetime DEFAULT NULL,
  PRIMARY KEY (`uid`) USING BTREE,
  UNIQUE KEY `uni_key` (`ws_uid`,`user_uid`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin ROW_FORMAT=DYNAMIC COMMENT='工作空间用户表';

-- ----------------------------
-- Records of tb_snb_ws_user
-- ----------------------------
BEGIN;
INSERT INTO `tb_snb_ws_user` VALUES ('0242ac11000a-11ed2a86-6affffbe-88c3', '0242ac11000a-11ed2a86-6affee3e-88c3', '0242ac11000a-11ed2a86-5db8b684-88c3', 'Admin', 1, '2022-09-02 14:13:53', '2023-01-10 14:04:14');
INSERT INTO `tb_snb_ws_user` VALUES ('11111111111111111111111111111111', '0242ac11001b-11ed258b-2697c2bc-91bd', '0242ac11001b-11ed258b-1f2b1362-91bd', 'Admin', 1, '2022-08-26 16:20:44', '2023-02-08 00:59:07');
COMMIT;

-- ----------------------------
-- Table structure for tb_sys_shortcut
-- ----------------------------
DROP TABLE IF EXISTS `tb_sys_shortcut`;
CREATE TABLE `tb_sys_shortcut` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(46) DEFAULT NULL COMMENT '快捷键名称',
  `shortcut_key` varchar(255) DEFAULT NULL COMMENT '快捷键',
  `instructions` varchar(255) DEFAULT NULL COMMENT '说明\n',
  `category` varchar(255) DEFAULT NULL COMMENT '类别',
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  `update_time` datetime DEFAULT NULL COMMENT '修改时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=39 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;

-- ----------------------------
-- Records of tb_sys_shortcut
-- ----------------------------
BEGIN;
INSERT INTO `tb_sys_shortcut` VALUES (3, '版本保存', 'Ctrl + S', '版本保存', '文档级', NULL, NULL);
INSERT INTO `tb_sys_shortcut` VALUES (4, '编辑状态', 'Enter', '命令状态 --转化为--&gt;编辑状态', '代码块（Cell）状态', NULL, NULL);
INSERT INTO `tb_sys_shortcut` VALUES (5, '命令状态', 'Esc', '编辑状态--转化为--&gt;命令状态', '代码块（Cell）状态', NULL, NULL);
INSERT INTO `tb_sys_shortcut` VALUES (9, '运行当前单元格(cell)', 'Ctrl + Enter', '运行当前单元格(cell)', '命令模式', NULL, NULL);
INSERT INTO `tb_sys_shortcut` VALUES (10, '运行当前单元格(cell)，并选定下面一个单元格', 'Shift + Enter', '运行当前单元格(cell)，并选定下面一个单元格', '命令模式', NULL, NULL);
INSERT INTO `tb_sys_shortcut` VALUES (11, '运行当前单元格(cell)，并下面插入一个code 单元格(code cell)', 'Alt + Enter', '运行当前单元格(cell)，并下面插入一个code 单元格(code cell)', '命令模式', NULL, NULL);
INSERT INTO `tb_sys_shortcut` VALUES (13, '删除当前CELL', 'D + D', '删除当前CELL', '命令模式', NULL, NULL);
INSERT INTO `tb_sys_shortcut` VALUES (14, '在当前单元格前插入Code单元格', 'A', '插入Code单元格', '命令模式', NULL, NULL);
INSERT INTO `tb_sys_shortcut` VALUES (15, '在当前单元格后插入Code单元格', 'B', '插入Code单元格', '命令模式', NULL, NULL);
INSERT INTO `tb_sys_shortcut` VALUES (16, '单元格复制', 'C', '单元格复制', '命令模式', NULL, NULL);
INSERT INTO `tb_sys_shortcut` VALUES (17, '单元格剪切', 'X', '单元格剪切', '命令模式', NULL, NULL);
INSERT INTO `tb_sys_shortcut` VALUES (18, '在当前单元格下面黏贴', 'V', '单元格黏贴', '命令模式', NULL, NULL);
INSERT INTO `tb_sys_shortcut` VALUES (20, '列选择', 'Ctrl + Alt + ↓', '列选择', '编辑模式', NULL, NULL);
INSERT INTO `tb_sys_shortcut` VALUES (21, '向上/向下复制行', 'Shift + Alt + ↓ / ↑', '向上/向下复制行', '编辑模式', NULL, NULL);
INSERT INTO `tb_sys_shortcut` VALUES (22, '剪切行', 'Ctrl + X', '剪切行', '编辑模式', NULL, NULL);
INSERT INTO `tb_sys_shortcut` VALUES (23, '复制行', 'Ctrl + C', '复制行', '编辑模式', NULL, NULL);
INSERT INTO `tb_sys_shortcut` VALUES (24, '上下移动', 'ALT + ↑ / ↓', '上下移动', '编辑模式', NULL, NULL);
INSERT INTO `tb_sys_shortcut` VALUES (25, '缩进', 'Ctrl + ] / [', '缩进', '编辑模式', NULL, NULL);
INSERT INTO `tb_sys_shortcut` VALUES (26, '转到行的开头/转到行的末尾', 'Home / End', '转到行的开头/转到行的末尾', '编辑模式', NULL, NULL);
INSERT INTO `tb_sys_shortcut` VALUES (27, '切换行注释', 'Ctrl + /', '切换行注释', '编辑模式', NULL, NULL);
INSERT INTO `tb_sys_shortcut` VALUES (28, '添加文本块 \'\'\' \'\'\'', 'shift + Alt + A', '\'\'\' \'\'\'', '编辑模式', NULL, NULL);
INSERT INTO `tb_sys_shortcut` VALUES (29, '跳转到行', 'Ctrl + G', '跳转到行', '编辑模式', NULL, NULL);
INSERT INTO `tb_sys_shortcut` VALUES (30, '查找', 'Ctrl + F', '查找', '编辑模式', NULL, NULL);
INSERT INTO `tb_sys_shortcut` VALUES (31, '替换', 'Ctrl + H', '替换', '编辑模式', NULL, NULL);
INSERT INTO `tb_sys_shortcut` VALUES (32, '撤消上一个光标操作', 'Ctrl + U', '撤消上一个光标操作', '编辑模式', NULL, NULL);
INSERT INTO `tb_sys_shortcut` VALUES (33, '选择当前字的所有出现', 'Ctrl + F2', '选择当前字的所有出现', '编辑模式', NULL, NULL);
INSERT INTO `tb_sys_shortcut` VALUES (34, '展开选择', 'Shift + Alt + →', '展开选择', '编辑模式', NULL, NULL);
INSERT INTO `tb_sys_shortcut` VALUES (35, '缩小选择', 'Shift + Alt + ←', '缩小选择', '编辑模式', NULL, NULL);
INSERT INTO `tb_sys_shortcut` VALUES (36, '单元格撤销', 'Ctrl + Z', '单元格撤销', '命令模式', NULL, NULL);
INSERT INTO `tb_sys_shortcut` VALUES (37, '重复上一步', 'Shift + Ctrl + Z', '重复上一步', '命令模式', NULL, NULL);
COMMIT;

-- ----------------------------
-- Table structure for test
-- ----------------------------
DROP TABLE IF EXISTS `test`;
CREATE TABLE `test` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `x` varchar(45) DEFAULT NULL,
  `y` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=153 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;

-- ----------------------------
-- Records of test
-- ----------------------------
BEGIN;
INSERT INTO `test` VALUES (151, '1', 'john');
INSERT INTO `test` VALUES (152, '800', '大富大是');
COMMIT;

CREATE TABLE `tb_snb_portal_menu` (
  `uid` varchar(36) NOT NULL COMMENT '菜单UID',
  `name` varchar(45) DEFAULT NULL COMMENT '菜单名称：英文',
  `label` varchar(45) DEFAULT NULL COMMENT '菜单显示名称：中文/英文',
  `dashboard_uid` varchar(36) DEFAULT NULL COMMENT '仪表盘UID，可以为空',
  `url` varchar(256) DEFAULT NULL COMMENT '菜单对应的URL ',
  `ws_uid` varchar(36) DEFAULT NULL COMMENT 'workspace UID',
  `parent_uid` varchar(36) DEFAULT NULL COMMENT '上级UID',
  `is_display` int(11) DEFAULT '1' COMMENT '是否显示，1 显示，0 为不显示',
  `remarks` varchar(128) DEFAULT NULL COMMENT '备注',
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  `update_time` datetime DEFAULT NULL COMMENT '修改时间',
  `authority` varchar(45) DEFAULT NULL COMMENT '权限控制：\nNO ：所有人都可以访问\nINCLUDE : 包含列表中的才可以访问\nEXCLUDE: 列表中之外的用户才可以访问',
  `users_uid` varchar(512) DEFAULT NULL COMMENT '用户列表 ;分割',
  `sort_value` float DEFAULT '0' COMMENT '排序字段',
  PRIMARY KEY (`uid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='数据门户数据的菜单管理';

ALTER TABLE `snb_server_db`.`tb_snb_ws_environment`
CHANGE COLUMN `cntr_node_hostname` `cntr_node_hostname` VARCHAR(64) NULL DEFAULT NULL COMMENT '所在节点的机器名称' ,
CHANGE COLUMN `cntr_node_ip` `cntr_node_ip` VARCHAR(64) NULL DEFAULT NULL COMMENT '所在节点的ip地址' ;


DROP TABLE IF EXISTS `tb_snb_ws_ds_mongodb`;
CREATE TABLE `tb_snb_ws_ds_mongodb` (
  `ds_uid` varchar(36) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `ds_type` varchar(16) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL COMMENT '数据类型：mysql、oracle、hive、impala......',
  `ws_uid` varchar(36) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
  `db_host` varchar(45) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
  `db_port` int(11) DEFAULT NULL,
  `db_user` varchar(45) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
  `db_database` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
  `db_password` varchar(256) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL COMMENT 'AES密码加密，加密参照snb_security  AES256$6096c65a20e2679064b3db3982c420a64efb1a485a499e793a3df0149185bc7b$87daaca9c46e98024484410112d98024',
  PRIMARY KEY (`ds_uid`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;

ALTER TABLE `snb_server_db`.`tb_snb_portal_menu`
ADD COLUMN `hide_header` INT NULL DEFAULT 0 COMMENT '是否隐藏头部' AFTER `sort_value`;

CREATE TABLE `tb_snb_ws_theme` (
  `uid` varchar(36) NOT NULL COMMENT '主题',
  `ws_uid` varchar(36) DEFAULT NULL COMMENT '所属的ws_id',
  `control_type` varchar(45) DEFAULT NULL COMMENT '控件类型：\nDS_UI: dashboard可视化控件\nINTERACT：interact交互组件\nTEMPLATE： 模板，protal或login 登录页\n',
  `control_name` varchar(45) DEFAULT NULL,
  `theme_label` varchar(64) DEFAULT NULL COMMENT '主题名称，中文',
  `theme_name` varchar(64) DEFAULT NULL COMMENT '主题英文名称',
  `theme_content` text COMMENT '主题内容\n',
  `theme_show` text COMMENT '风格展现示例',
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  `update_time` datetime DEFAULT NULL COMMENT '修改时间',
  `theme_show_file` varchar(128) DEFAULT NULL COMMENT '虚拟的字段，没有用处',
  PRIMARY KEY (`uid`),
  UNIQUE KEY `name_uni` (`ws_uid`,`theme_name`,`control_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='主题模板';




SET FOREIGN_KEY_CHECKS = 1;
