hahastephanie
hahastephanie
2020-06-13 09:59
采纳率: 13.3%
浏览 729

急!python运行后什么都不输出

import pandas as pd
from sqlalchemy import create_engine

connect_info = "mysql+mysqlconnector://root:passwd@localhost:3306/inventory?charset=utf8mb4"
auth_plugin='mysql_native_password'
engine = create_engine(connect_info) #use sqlalchemy to build link-engine

sql1 = "select * from colors" #SQL query
df1 = pd.read_sql_query(sql1, con=engine, index_col=None,
                       coerce_float=True, params=None, parse_dates=None,chunksize=None)
# #df = pd.read_sql(sql=sql,con=engine) #read data to DataFrame 'df'
#
# #显示所有列
pd.set_option('display.max_columns',10)
# #显示所有行
pd.set_option('display.max_rows', 10)
#
# # get the number of missing data points per column
missing_values_count = df1.isnull().sum()
#
# # look at the # of missing points in the first ten columns
missing_values_count[0:10]

运行结果什么都没有输出,为什么呢?求大佬解答!!

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • caozhy
    已采纳

    df1 = pd.read_sql_query(sql1, con=engine, index_col=None,
    coerce_float=True, params=None, parse_dates=None,chunksize=None)
    下面加上
    print(df1)
    看看

    再有,检查下数据库里面colors表有没有数据

    点赞 评论

相关推荐