KDB/Q逐行添加两个表



我有两个具有相同列的表我想像一样,用每两个表的行创建一个表

ask  ask_qty exchange_name_ask       bid  bid_qty exchange_name_bid
0  19166.73   0.0260           b'Gate'  19164.61   0.1042           b'Gate'
1  19167.21   0.0521           b'Gate'  19164.16   0.0103           b'Gate'
2  19167.63   0.1200           b'Gate'  19163.92   0.0296           b'Gate'
3  19168.27   0.1304           b'Gate'  19162.39   0.1304           b'Gate'

ask  ask_qty exchange_name_ask       bid  bid_qty exchange_name_bid
0  19169.13   0.1200           b'CoinBase'  19159.90   0.1200           b'CoinBase'
1  19171.36   0.2608           b'CoinBase'  19158.95   0.0291           b'CoinBase'
2  19172.18   0.5215           b'CoinBase'  19158.69   0.0106           b'CoinBase'
3  19173.59   0.0102           b'CoinBase'  19157.86   0.2609           b'CoinBase'

获取

ask  ask_qty exchange_name_ask       bid  bid_qty exchange_name_bid
0  19166.73   0.0260           b'Gate'  19164.61   0.1042           b'Gate'
1  19167.21   0.0521           b'Gate'  19164.16   0.0103           b'Gate'
2  19167.63   0.1200           b'Gate'  19163.92   0.0296           b'Gate'
3  19168.27   0.1304           b'Gate'  19162.39   0.1304           b'Gate'
4  19169.13   0.1200           b'CoinBase'  19159.90   0.1200           b'CoinBase'
5  19171.36   0.2608           b'CoinBase'  19158.95   0.0291           b'CoinBase'
6  19172.18   0.5215           b'CoinBase'  19158.69   0.0106           b'CoinBase'
7  19173.59   0.0102           b'CoinBase'  19157.86   0.2609           b'CoinBase'

感谢

给定表具有匹配的模式,仅join (,)就足够了:

gateTbl,coinbaseTbl

假设表a和表b为

a uj b
or
a,b

您可以在这里使用联合联接,因为您的表没有键,表只是相互附加。

https://code.kx.com/q/ref/uj/有更多关于uj的有用信息。

正如其他人所建议的,您可以执行table1、table2或[table1;table2],因为您的列和模式是相同的。

最新更新