将pandas字符串的数据帧转换为int的numpy数组(convert pandas dataframe of strings to numpy array of int)
我的输入是一个带有字符串的pandas数据帧:
>>> data 218.0 221.0 222.0 224.0 71,299,77,124 227.0 50,283,81,72 229.0 231.0 84,349 233.0 235.0 240.0 53,254 Name: Q25, dtype: object
现在我想要一个形状(.reshape(-1,2))numpy数组的int为每一行像这样:
>>> data 218.0 [] 221.0 [] 222.0 [] 224.0 [[71,299], [77,124]] 227.0 [[50,283], [81,72]] 229.0 [] 231.0 [[84,349]] 233.0 [] 235.0 [] 240.0 [[53,254]] Name: Q25, dtype: object
我不知道如何通过矢量操作到达那里。 有人可以帮忙吗?
My input is a pandas dataframe with strings inside:
>>> data 218.0 221.0 222.0 224.0 71,299,77,124 227.0 50,283,81,72 229.0 231.0 84,349 233.0 235.0 240.0 53,254 Name: Q25, dtype: object
now i want a shaped ( .reshape(-1,2) ) numpy array of ints for every row like that:
>>> data 218.0 [] 221.0 [] 222.0 [] 224.0 [[71,299], [77,124]] 227.0 [[50,283], [81,72]] 229.0 [] 231.0 [[84,349]] 233.0 [] 235.0 [] 240.0 [[53,254]] Name: Q25, dtype: object
i dont know how to get there by vector operations. can someone help?
原文:https://stackoverflow.com/questions/51086721
更新时间:2023-01-11 20:01
最满意答案
做一些像:
var script = { callAction: function () { $.ajax({ url: 'Home/MapTest', type:'GET', data: JSON.stringify({ date: "your date" }) dataType: "json", success: function (message) { var count = message.length; for (var i = 0; i < count; i++) { $('#maplong').append(message[i].LATITUDE, " ", message[i].LONGITUDE," "); } }, complete: function () { alert('completed'); } }); } }
最好的祝福
Just do something like:
var script = { callAction: function () { $.ajax({ url: 'Home/MapTest', type:'GET', data: JSON.stringify({ date: "your date" }) dataType: "json", success: function (message) { var count = message.length; for (var i = 0; i < count; i++) { $('#maplong').append(message[i].LATITUDE, " ", message[i].LONGITUDE," "); } }, complete: function () { alert('completed'); } }); } }
Best Regards
相关问答
更多-
通过本地客户端程序获取服务器mysql数据库信息[2023-04-27]
ajax -
为什么不创建一个返回JSON响应的函数,您可以包含所需的所有数据。 我更喜欢为这些类型的东西创建.ashx处理程序,并返回一个非常容易调用并处理客户端的JSON响应。 Why not create a function that returns a JSON response which you could include all the data you need. I prefer to create .ashx handlers for these types of things and return ...
-
通过Ajax传递参数(Passing parameter via Ajax)[2024-01-22]
这是一个HTTP POST方法,但您尝试传递参数,就像它是HTTP GET一样。 我从来没有看到它写在哪里你可以像HTTP GET一样在URL中指定参数。 请注意,我在下面添加了JSON数据行。 这就是填写你的帖子请求。 data: '{textIndex: "' + indexNumber + '" }', 整个功能: function ReceivedMessage(indexNumber) { $.ajax({ type: "Post", url: "Def ... -
做一些像: var script = { callAction: function () { $.ajax({ url: 'Home/MapTest', type:'GET', data: JSON.stringify({ date: "your date" }) dataType: "json", success: function (message) { ...
-
你可能喜欢这样 $(function() { $('.ajax-link').click(function() { var user=$(this).data('user'); $.get("/"+$(this).data('url')+"/user="+user, function(msg) { alert("Data Saved: " + msg); $("#status" + user).html("some content"); ...
-
参数和AJAX,PHP(Parameters and AJAX, PHP)[2021-12-26]
继developerCK提到的关于此行中jQuery语法错误的内容: var id = $('#code').val; // Should be: var id = $('#code').val(); 通过切换到AJAX请求的jQuery语法,您可以节省大量的输入。 以下是jQuery / AJAX入门的一些帖子: 一个简单的例子 更复杂的例子 根据下拉列表1中的选择填充下拉列表2 Further to what developerCK mentioned regarding the jQuery sy ... -
Prototype在调用Responders回调之前设置参数数组,因此您不能只将参数哈希添加到参数哈希中。 您可以将变量附加到url,例如,这将为每个请求添加一个缓存buster随机数... Ajax.Responders.register({ onCreate: function(o,x) { o.url += (o.url.include('?') ? '&' : '?') + "rnd=" + Math.floor(Math.random()*1000000000); } }); ...
-
添加Douglas Crockford着名的json2.js,并使用特征检测来polyfill json序列化以实现兼容性 https://github.com/douglascrockford/JSON-js 来自文件: JSON.stringify(value, replacer, space) value any JavaScript value, usually an object or array. replacer an optional parameter that det ...
-
这是意图吗? $.ajax({ url : ajaxOverallUrl, data : ajaxDataLink, dataType : 'json', type : 'get', async : true, success : function(data) {}, complete: function(){a();b();} }); Is this the intent ? $.ajax({ url : ajaxOverallUrl, data : ajaxData ...
-
在您当前的代码中执行以下操作(将数据添加到序列化表单本身): - data:$('#Form1').serialize()+ '&CountryId=' + CountryId, 或者你可以使用serializeArray [docs] var data = $('#myForm').serializeArray(); data.push({name: 'CountryId', value: CountryId}); Do it like below in your current code (wi ...