鱼C论坛

 找回密码
 立即注册
查看: 1770|回复: 7

求大佬看一下问题在哪里

[复制链接]
发表于 2020-6-27 17:48:11 | 显示全部楼层
[b]把 最外面的  try-except 删了 看看报错在第几行呀[/b]
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-6-27 17:53:36 | 显示全部楼层
开始吧我 发表于 2020-6-27 17:52
这一行df_mean=pd.read_excel(fn,encoding='cp936')


报错内容看看~
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-6-27 17:58:51 | 显示全部楼层
开始吧我 发表于 2020-6-27 17:54
IndentationError: unexpected indent

....这个是缩进问题?
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-6-27 18:25:56 | 显示全部楼层
开始吧我 发表于 2020-6-27 18:00
大佬,我真的发现不了错误呀,┭┮﹏┭┮



我也不懂了,你重新复制运行看看:

  1. import pandas as pd
  2. import numpy as np
  3. import matplotlib.pyplot as plt


  4. def dataDescribeVisualization():
  5.     while True:
  6.         # 读取数据
  7.         fn = input('请输入文件名: ')
  8.         try:
  9.             df_mean = pd.read_excel(fn, encoding='cp936')
  10.             df_mean_describe = df_mean.describe()
  11.             print(type(df_mean_describe))  # <class'pandas.core.frame.DataFrame'>
  12.             print(df_mean_describe)
  13.             maxValue = df_mean_describe.at['max', 'atemp']
  14.             minValue = df_mean_describe.at['min', 'atemp']
  15.             meanValue = df_mean_describe.at['mean', 'atemp']
  16.             # 将 atemp 进行离散化
  17.             category = [minValue, 0.4, 0.6, 0.8, maxValue]
  18.             labels = ['Cold', 'Cool', 'Warm', 'Hot']
  19.             # 利用cut函数
  20.             df['Label'] = pd.cut(df['atemp'], category, labels=labels)
  21.             try:
  22.                 df.to_csv('bike_atemp_user_cnt_result.csv', index=False)
  23.                 print('任务四完成')
  24.                 break
  25.             except:
  26.                 print('文件导出失败')
  27.         except:
  28.             print('文件名错误,请重试: ')


  29. dataDescribeVisualization()
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-10-11 03:14

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表