小编a12*_*234的帖子

SQL Server查询以获取表中所有列的数据类型?

我有这个在SSMS中运行的SQL Server 2012查询:

SELECT name, max_length, precision, scale, is_nullable 
FROM sys.columns
WHERE object_id = OBJECT_ID('dbo.testtable')
Run Code Online (Sandbox Code Playgroud)

它正在回归我想要的东西:

在此输入图像描述

但是,我想在此查询中添加列的数据类型,以便它看起来像我在对象资源管理器中看到的那样.有关如何添加数据类型的任何想法?

在此输入图像描述

sql-server

4
推荐指数
2
解决办法
3万
查看次数

带有熊猫系列的 matplotlib 双条形图

我有以下几点:

indyes = tuple(yesSeries.index)
indno = tuple(nodSeries.index)
width = 3

p1 = plt.bar(indyes, yesSeries, label="Example one", color='SkyBlue')
p2 = plt.bar(indno, nodSeries, label="Example two", color='IndianRed')
plt.legend()
plt.xlabel('bar number')
plt.ylabel('bar height')

plt.title('Epic Graph\nAnother Line! Whoa')

plt.show()
Run Code Online (Sandbox Code Playgroud)

它将我的图形绘制为堆积条形图: 在此处输入图片说明

当我尝试添加+ width到第二个条形图时,indno + width它们没有堆叠,而是并排,我收到以下错误:TypeError: can only concatenate tuple (not "int") to tuple

我已将 Pandas 系列设置为一个元组以提取日期和计数信息。

如何获得两个平行的垂直条形图?

tuples matplotlib bar-chart pandas

3
推荐指数
1
解决办法
5534
查看次数

pandas 行中的最大值并返回 df 以及值和列名称

我有以下数据框:

    a    b    c    d    e
    1   .90  .95  .83  .56
   .95  .96  .87  .83  .63
   .83  .87  .83  .95  .81
Run Code Online (Sandbox Code Playgroud)

如何找到每行及其来自的列的最大值,使其看起来像:

a   1
b  .96
d  .95
Run Code Online (Sandbox Code Playgroud)

python python-3.x pandas

3
推荐指数
2
解决办法
3205
查看次数

熊猫按周分组

我有以下test数据框:

       date                 user  answer  
0      2018-08-19 19:08:19  pga   yes   
1      2018-08-19 19:09:27  pga   no   
2      2018-08-19 19:10:45  lry   no   
3      2018-09-07 19:12:31  lry   yes
4      2018-09-19 19:13:07  pga   yes   
5      2018-10-22 19:13:20  lry   no
Run Code Online (Sandbox Code Playgroud)

我正在使用以下代码按周分组:

test.groupby(pd.Grouper(freq='W'))
Run Code Online (Sandbox Code Playgroud)

我收到一个错误,指出Grouper仅对DatetimeIndex有效,但是我不熟悉如何按周分组的结构。

grouping group-by pandas

2
推荐指数
1
解决办法
1679
查看次数

熊猫重命名索引

我有以下数据框,我想在其中将索引重命名summaryid

summary  student  count 
0        error    6
1        yes      1
2        no       1
3        other    9
Run Code Online (Sandbox Code Playgroud)

我试过: newdf = df.reset_index().rename(columns={df.index.name:'foo'})它给出:

summary  index    student  count    
0        0        error   6
1        1        yes     1
2        2        no      1
3        3        other   9
Run Code Online (Sandbox Code Playgroud)

我也试过:df.index.rename('foo', inplace = True)它给出:

 summary     student  count
 foo        
 0           error    6
 1           yes      1
 2           no       1
 3           other    9
Run Code Online (Sandbox Code Playgroud)

我也试过:df.rename_axis('why', inplace = True)它给出:

 summary     student  count
 why        
 0           error    6 …
Run Code Online (Sandbox Code Playgroud)

python pandas

2
推荐指数
2
解决办法
1万
查看次数

DATEADD从现在起30天内不包括一天

我有一个SQL查询...

当我从今天的日期开始运行此查询时,我将获得从2016年7月22日返回的记录.

SELECT test_id, lat, long
FROM  testDB.src.test_20
WHERE test_date >= DATEADD(day,-32, GETDATE()) and lat is not null and long is not null 
Run Code Online (Sandbox Code Playgroud)

当我将DATEADD功能更改为-31时,我将从2016年7月23日获得记录.

SELECT test_id, lat, long
FROM  testDB.src.test_20
WHERE test_date >= DATEADD(day,-31, GETDATE()) and lat is not null and long is not null
Run Code Online (Sandbox Code Playgroud)

我可能不清楚DATEADD函数是如何工作的.我认为使用-31时会发生的是从今天到第31天的记录,包括2016年7月22日的记录将被退回(从31天前的今天起是2016年7月22日).

为什么使用-31时未返回2016年7月22日的记录?

SQL Server Management Studio 2012

sql-server date sql-server-2012

1
推荐指数
1
解决办法
479
查看次数

重新格式化 JSON 文件?

我有两个 JSON 文件。

文件A:

  "features": [
  {
   "attributes": {
    "NAME": "R T CO",
    "LTYPE": 64,
    "QUAD15M": "279933",
    "OBJECTID": 225,
    "SHAPE.LEN": 828.21510830520401
   },
   "geometry": {
    "paths": [
     [
      [
       -99.818614674337155,
       27.782542677671653
      ],
      [
       -99.816056346719051,
       27.782590806976135
      ]
     ]
    ]
   }
  }
Run Code Online (Sandbox Code Playgroud)

文件乙:

  "features": [
{
  "geometry": {
    "type": "MultiLineString",  
    "coordinates": [
      [
        [
          -99.773315512624,
          27.808875128096
        ],
        [
          -99.771397939251,
          27.809512259374
        ]
      ]
    ]
  },
  "type": "Feature",
  "properties": {
    "LTYPE": 64,
    "SHAPE.LEN": 662.3800009247,
    "NAME": "1586",
    "OBJECTID": 204,
    "QUAD15M": "279933"
  }
},
Run Code Online (Sandbox Code Playgroud)

我希望将文件 B 重新格式化为文件 …

python json reformatting

1
推荐指数
1
解决办法
1250
查看次数

python Fuzzywuzzy 限制,它是如何工作的?

极限是如何与 python 的fuzzywuzzy 模块一起工作的,它是什么意思?

matches = process.extract(query, choices, limit=2, scorer=fuzz.partial_ratio)
Run Code Online (Sandbox Code Playgroud)

fuzzy fuzzy-logic python-3.x fuzzywuzzy

1
推荐指数
1
解决办法
1346
查看次数

如何使用正则表达式和python从URL解析经度/纬度?

我有网址: https://maps.google.com/maps?ll=44.864505,-93.44873&z=18&t=m&hl=en&gl=US&mapclient=apiv3

我想从网址中提取经/纬度,这样我就可以了44.864505,-93.44873

到目前为止,我拥有(^[maps?ll=]*$|(?<=\?).*)*给我的东西,ll=44.864505,-93.44873&z=18&t=m&hl=en&gl=US&mapclient=apiv3 但这需要改进。我一直在尝试使用pythex来解决这个问题,但是我被困住了。

有什么建议么?谢谢

python regex

0
推荐指数
1
解决办法
65
查看次数