我正在尝试使用 Heroku 提供 Dash 应用程序。我的应用中有 5 个文件:
.gitignore
venv
*.pyc
.DS_Store
.env
Run Code Online (Sandbox Code Playgroud)
应用程序
import os
import dash
import dash_core_components as dcc
import dash_html_components as html
import plotly.graph_objs as go
import pandas as pd
# Read in the data
districts_change = pd.read_csv("https://github.com/thedatasleuth/New-York-Congressional-Districts/blob/master/districts_change.csv?raw=True")
df = districts_change.drop(['TOTAL'], axis=1)
# Get a list of all the districts
districts = districts_change['DISTRICT'].unique()
# Create the app
app = dash.Dash()
# Populate the layout with HTML and graph components
app.layout = html.Div([
html.H2("New York Congressional Districts"),
html.Div( …Run Code Online (Sandbox Code Playgroud) 我正在尝试获取表中每列的非空值的计数。我研究了以下先前提出的SO问题,但没有找到满意的答案:
我编写了以下代码,以尝试为我的表构建一个数据字典,以包括列的名称,每列中填充的行数,数据类型,长度以及它是否为主键:
SELECT
c.name 'Column Name',
p.rows 'Row_Count',
t.Name 'Data type',
c.max_length 'Max Length',
ISNULL(i.is_primary_key, 0) 'Primary Key'
FROM
sys.columns c
INNER JOIN
sys.types t ON c.user_type_id = t.user_type_id
LEFT OUTER JOIN
sys.index_columns ic ON ic.object_id = c.object_id AND ic.column_id = c.column_id
LEFT OUTER JOIN
sys.indexes i ON ic.object_id = i.object_id AND ic.index_id = i.index_id
LEFT OUTER JOIN
sys.partitions p ON p.OBJECT_ID = i.OBJECT_ID and i.index_id = p.index_id
WHERE
c.object_id = OBJECT_ID('my_table')
Run Code Online (Sandbox Code Playgroud)
但是,Row_Count列返回所有Null。
我的预期结果如下所示:
Column_Name …Run Code Online (Sandbox Code Playgroud)