我已经看过几个关于这个的帖子,但我无法理解merge,join和concat如何解决这个问题.如何合并两个数据帧以查找匹配的索引?
在:
import pandas as pd
import numpy as np
row_x1 = ['a1','b1','c1']
row_x2 = ['a2','b2','c2']
row_x3 = ['a3','b3','c3']
row_x4 = ['a4','b4','c4']
index_arrays = [np.array(['first', 'first', 'second', 'second']), np.array(['one','two','one','two'])]
df1 = pd.DataFrame([row_x1,row_x2,row_x3,row_x4], columns=list('ABC'), index=index_arrays)
print(df1)
Run Code Online (Sandbox Code Playgroud)
出:
A B C
first one a1 b1 c1
two a2 b2 c2
second one a3 b3 c3
two a4 b4 c4
Run Code Online (Sandbox Code Playgroud)
在:
row_y1 = ['d1','e1','f1']
row_y2 = ['d2','e2','f2']
df2 = pd.DataFrame([row_y1,row_y2], columns=list('DEF'), index=['first','second'])
print(df2)
Run Code Online (Sandbox Code Playgroud)
出
D E F
first d1 e1 f1
second d2 …
Run Code Online (Sandbox Code Playgroud) 我想对记录进行分组并_id
通过组合client_id
值来创建一个字符串。
以下是我的文档示例:
{
"_id" : ObjectId("59e955e633d64c81875bfd2f"),
"tag_id" : 1,
"client_id" : "10001"
}
{
"_id" : ObjectId("59e955e633d64c81875bfd30"),
"tag_id" : 1,
"client_id" : "10002"
}
Run Code Online (Sandbox Code Playgroud)
我想要这个输出:
{
"_id" : 1
"client_id" : "10001,10002"
}
Run Code Online (Sandbox Code Playgroud) 我有以下列表:
我想将这些字符串转换为一个字符串,逗号分隔,但我想首先为它们添加一个字符(@符号).最终结果应该是:@alpha,@beta,@charlie,@delta
我现在拥有的是非LINQ方法,但它似乎并不"干净":
String.Concat("@", String.Join(",@", mylist));
Run Code Online (Sandbox Code Playgroud) 如何找到每个页面的所有标签,然后将标签连成一列?
举个例子,
页表,
page_id
1
2
3
4
Run Code Online (Sandbox Code Playgroud)
标签表,
tag_id tag_name
1 A
2 B
3 C
4 D
Run Code Online (Sandbox Code Playgroud)
标记表,
page_id tag_id
1 1
1 2
1 3
3 2
3 3
Run Code Online (Sandbox Code Playgroud)
我的工作查询,
SELECT
p.page_id,
GROUP_CONCAT(t.tag_name ORDER BY t.tag_name ASC SEPARATOR ",") AS tags
FROM root_pages AS p
LEFT JOIN root_mm_pages_tags AS m
ON p.page_id = m.page_id
LEFT JOIN root_tags AS t
ON t.tag_id = m.tag_id
WHERE p.page_id = t.page_id
Run Code Online (Sandbox Code Playgroud)
这是我追求的结果,
page_id tags
1 A, B, C
2 NULL
3 …
Run Code Online (Sandbox Code Playgroud) 在SQL Server 2012中我希望concat
5列成1但在查询中它可以工作但是当我放入视图时它会给我一个错误
Msg 174,Level 15,State 1,Line 3
CONCAT功能需要2个参数.
有什么问题所以我可以解决它,因为它concat
是一个concatenate
超过1列的好函数,因为如果它为null,它们会使它为空.
码:
SELECT
'Aan ' + A.Name AS 'Naam',
{ fn CONCAT('T.a.v. ', C.Salutation + ' ', C.FirstName + ' ', C.MiddleName + ' ', C.LastName) } AS 'T.a.v.',
ISNULL(ISNULL(A.Address1_Line2, A.Address1_Line1),
C.Address1_Line2) AS 'Adres',
ISNULL(A.Address1_PostalCode + ' ' + A.Address1_City, A.Address2_PostalCode + ' ' + A.Address2_City) AS 'Woonplaats',
'heer' + ' ' + ISNULL(C.MiddleName + ' ', N'') + ISNULL(C.LastName, N'') AS 'Aanhef'
FROM
dbo.Account …
Run Code Online (Sandbox Code Playgroud) 我正在使用Teradata,我有一张这样的桌子
ID String
123 Jim
123 John
123 Jane
321 Jill
321 Janine
321 Johan
Run Code Online (Sandbox Code Playgroud)
我想查询表,所以我得到了
ID String
123 Jim, John, Jane
321 Jill, Janine, Johan
Run Code Online (Sandbox Code Playgroud)
我试过分区,但可以有很多名字.我如何得到这个结果.甚至,指出我正确的方向将是伟大的.
连接两个浏览器化文件(vendor.js和app.js到combined.js)时遇到问题
在浏览器中加载combined.js会在_prelude.js中抛出以下内容:
Uncaught Error: Cannot find module 'function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}'
Run Code Online (Sandbox Code Playgroud)
单独加载浏览器化文件时工作得很好.
我错过了什么?
(如果您需要更多配置,请告诉我,很高兴提供)
谢谢你的帮助!
在Gruntfile.js中:
browserify: {
vendor: {
src: ['client/requires/**/*.js'],
dest: 'build/vendor.js',
options: {
shim: {
jquery: {
path: 'client/requires/jquery/js/jquery.js',
exports: '$'
},
underscore: {
path: 'client/requires/underscore/js/underscore.js',
exports: '_'
},
backbone: {
path: 'client/requires/backbone/js/backbone.js',
exports: 'Backbone',
depends: {
underscore: 'underscore'
}
},
'backbone.marionette': {
path: 'client/requires/backbone.marionette/js/backbone.marionette.js',
exports: 'Marionette',
depends: {
jquery: '$', …
Run Code Online (Sandbox Code Playgroud) 我想这与数组填充类似,但我想知道它是否可以简化.
var arr = [1,2,3],
x = 5;
for (var i=0; i<x; i++) {
arr.push(x);
}
console.log(arr);
//=> [1, 2, 3, 5, 5, 5, 5, 5]
Run Code Online (Sandbox Code Playgroud)
有没有办法在不使用for循环的情况下执行此操作?
更新
即使有移动器聪明的解决方案,for循环似乎是最高性能的
我试图一个接一个地连接一些mp4文件.我执行以下操作:
ffmpeg -i concat:1.mp4\|2.mp4\|3.mp4\|4.mp4 -c copy final_output.mp4
Run Code Online (Sandbox Code Playgroud)
但总是得到消息"[mov,mp4,m4a,3gp,3g2,mj2 @ 0x148d420]发现重复的MOOV Atom.跳过它"
这是输出:
ffmpeg version 2.4.2 Copyright (c) 2000-2014 the FFmpeg developers
built on Oct 6 2014 17:33:05 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
configuration: --prefix=/opt/ffmpeg --libdir=/opt/ffmpeg/lib/ --enable-shared --enable-avresample --disable-stripping --enable-gpl --enable-version3 --enable-runtime-cpudetect --build-suffix=.ffmpeg --enable-postproc --enable-x11grab --enable-libcdio --enable-vaapi --enable-vdpau --enable-bzlib --enable-gnutls --enable-libgsm --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libfaac --enable-libvo-aacenc --enable-nonfree --enable-libmp3lame --enable-libx264 --enable-libx265 --enable-libxvid --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libfdk_aac --enable-libopus --enable-pthreads --enable-zlib --enable-libvpx --enable-libfreetype --enable-libpulse --enable-debug=3
libavutil 54. 7.100 / 54. 7.100
libavcodec 56. 1.100 …
Run Code Online (Sandbox Code Playgroud) 所以我使用npm install uglify-js安装了npm
我运行的命令是:
cat file1.js file2.js .. fileN.js | uglifyjs -o files.min.js
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
WARN: ERROR: Unexpected token eof «undefined», expected punc «,» [-:630,15]
/usr/local/lib/node_modules/uglify-js/lib/parse.js:199
throw new JS_Parse_Error(message, line, col, pos);
^
Error
at new JS_Parse_Error (/usr/local/lib/node_modules/uglify-js/lib/parse.js:185:18)
at js_error (/usr/local/lib/node_modules/uglify-js/lib/parse.js:199:11)
at croak (/usr/local/lib/node_modules/uglify-js/lib/parse.js:630:9)
at token_error (/usr/local/lib/node_modules/uglify-js/lib/parse.js:638:9)
at expect_token (/usr/local/lib/node_modules/uglify-js/lib/parse.js:651:9)
at expect (/usr/local/lib/node_modules/uglify-js/lib/parse.js:654:36)
at ctor.argnames (/usr/local/lib/node_modules/uglify-js/lib/parse.js:897:52)
at function_ (/usr/local/lib/node_modules/uglify-js/lib/parse.js:902:15)
at expr_atom (/usr/local/lib/node_modules/uglify-js/lib/parse.js:1114:24)
at maybe_unary (/usr/local/lib/node_modules/uglify-js/lib/parse.js:1278:19)
Run Code Online (Sandbox Code Playgroud)
关于这是关于什么或我应该如何修复它的任何想法?
concat ×10
javascript ×2
arrays ×1
browserify ×1
c# ×1
ffmpeg ×1
ffserver ×1
group-by ×1
group-concat ×1
gruntjs ×1
linq ×1
list ×1
merge ×1
minify ×1
mongodb ×1
mp4 ×1
multi-index ×1
mysql ×1
npm ×1
pad ×1
pandas ×1
partition ×1
php ×1
python ×1
sql-server ×1
string ×1
tagging ×1
teradata ×1
uglifyjs ×1
video ×1