我正在尝试使用codeigniter将json从mysql数据返回给用户。在mysql中我有一个列作为点,当我调用mysql来获取数据时,我var_dump
信息就是这样。
array(1) { [0]=> object(stdClass)#19 (10) {
["ID"]=> string(1) "1"
["contact_email"]=> string(25) "awesome@awsm.com"
["owner_id"]=> string(1) "1"
["point"]=> string(25) "}�#�N@���ޯ�8@"
}
由于这些要点,当我尝试json编码和解码并将其发送回用户时,我得到NULL
值。
我不知道如何解决这个问题,它是一个codeigniter问题还是我如何设置我的数据库。
CREATE TABLE `foo` (
`ID` int(10) unsigned NOT NULL AUTO_INCREMENT,
`contact_email` varchar(100) NOT NULL,
`owner_id` int(100) NOT NULL,
`point` Point NOT NULL,
PRIMARY KEY (`ID`),
SPATIAL INDEX point_sx (`point`)
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARACTER SET utf8;
这就是insert语句的样子
INSERT INTO foo (contact_email,owner_id, point) VALUES ('awesome@awsm.com', 1, POINT('60.168607847624095','24.932371066131623'));
答案 0 :(得分:0)
更改您的插入过程,尝试将其插入如下,希望您能正确使用
import pandas as pd
from sklearn.preprocessing import Imputer
nonpredictors = ["Ticket", "Cabin", "Survived"]
nonpredictors_test = ["Ticket", "Cabin"]
training_df = pd.read_csv("train.csv").set_index(["PassengerId"])
training_df_concat = training_df.drop(nonpredictors, axis = 1)
testing_df = pd.read_csv("test.csv").set_index(["PassengerId"])
testing_df_concat = testing_df.drop(nonpredictors_test, axis = 1)
chunks = [training_df_concat, testing_df_concat]
all_data = pd.concat(chunks, ignore_index = True)
catVar = ["cabin_level", "Embarked", "Sex"]
all_data = pd.get_dummies(all_data, columns = catVar)
imp = Imputer(strategy = 'median')
imp.fit(all_data)
training_df = pd.get_dummies(training_df, columns = catVar)
train_x = training_df.drop(nonpredictors, axis = 1)
train_x = imp.transform(train_x)
train_y = training_df["Survived"]
testing_df = pd.get_dummies(testing_df, columns = catVar)
test_x = testing_df.drop(nonpredictors_test, axis = 1)
test_x = imp.transform(test_x)
ValueError: X has 20 features per sample, expected 21