RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / user-474754

Андрей's questions

Martin Hope
Андрей
Asked: 2022-09-01 20:03:49 +0000 UTC

Python没有看到table2变量[关闭]

  • -3
关闭 这个问题是题外话。目前不接受回复。

该问题是由不再复制的问题或错字引起的。虽然类似的问题可能与本网站相关,但该问题的解决方案不太可能帮助未来的访问者。通常可以通过在发布问题之前编写和研究一个最小程序来重现问题来避免此类问题。

3 个月前关闭。

改进问题

代码如下:

import pandas as pd

sum_row1 = table2.loc['row_1', 'D'] = table2.loc['row_1'].sum()
sum_row2 = table2.loc['row_1', 'D'] = table2.loc['row_2'].sum()
sum_row3 = table2.loc['row_1', 'D'] = table2.loc['row_3'].sum()
sum_row4 = table2.loc['row_1', 'D'] = table2.loc['row_4'].sum()

table2 = pd.DataFrame( data= [[11,21,10, sum_row1], [10, 30, 20, sum_row2], [11, 41, 30, sum_row3], [50, -100, 30, sum_row4] ] , index = ['row_1', 'row_2', 'row_3', 'row_4'], columns = ['B', 'D', 'E', 'sum'])

table2

结论:

---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
c:\Users\*USER*\Documents\hw7.ipynb Cell 1' in <cell line: 3>()
      1 import pandas as pd
----> 3 sum_row1 = table2.loc['row_1', 'D'] = table2.loc['row_1'].sum()
      4 sum_row2 = table2.loc['row_1', 'D'] = table2.loc['row_2'].sum()
      5 sum_row3 = table2.loc['row_1', 'D'] = table2.loc['row_3'].sum()

NameError: name 'table2' is not defined

有任何想法吗?

改变:

import pandas as pd


table2 = pd.DataFrame( data= [[11,21,10, sum_row1], [10, 30, 20, sum_row2], [11, 41, 30, sum_row3], [50, -100, 30, sum_row4] ] , index = ['row_1', 'row_2', 'row_3', 'row_4'], columns = ['B', 'D', 'E', 'sum'])

sum_row1 = table2.loc['row_1', 'D'] = table2.loc['row_1'].sum()
sum_row2 = table2.loc['row_1', 'D'] = table2.loc['row_2'].sum()
sum_row3 = table2.loc['row_1', 'D'] = table2.loc['row_3'].sum()
sum_row4 = table2.loc['row_1', 'D'] = table2.loc['row_4'].sum()


table2

新输出:

NameError                                 Traceback (most recent call last)
c:\Users\*USER*\Documents\hw7.ipynb Cell 1' in <cell line: 3>()
      1 import pandas as pd
----> 3 table2 = pd.DataFrame( data= [[11,21,10, sum_row1], [10, 30, 20, sum_row2], [11, 41, 30, sum_row3], [50, -100, 30, sum_row4] ] , index = ['row_1', 'row_2', 'row_3', 'row_4'], columns = ['B', 'D', 'E', 'sum'])
      5 sum_row1 = table2.loc['row_1', 'D'] = table2.loc['row_1'].sum()
      6 sum_row2 = table2.loc['row_1', 'D'] = table2.loc['row_2'].sum()

NameError: name 'sum_row1' is not defined
python pandas
  • 1 个回答
  • 24 Views
Martin Hope
Андрей
Asked: 2022-08-28 21:15:33 +0000 UTC

获取熊猫变量中的列总和

  • 0

有一个代码:

import pandas as pd
loc1 = *тут нужно получить сумму всех значений в row_1*
table2 = pd.DataFrame( data= [[11,21,10], [10, 30, 20], [11, 41, 30], [50, -100, loc1]  ] , index = ['row_1', 'row_2', 'row_3', 'row_4'], columns = ['B', 'D', 'E'])

table2

如何学习row_1的总和

python python-3.x
  • 1 个回答
  • 18 Views
Martin Hope
Андрей
Asked: 2022-08-14 03:57:15 +0000 UTC

自定义python模块中的导入问题

  • 1

写了我的模块:

import time


sec =  int(input())
min =  int(input())
hour = int(input())

if sec == '':
     sec = None
     exit(0)
if min == '':
    min = None
    exit(0)
if hour == '':
    hour = None
    exit(0) 
    

def time_to_seconds():
    second = (min * 60) + (hour * 3600) + sec
    return second
    
print(time_to_seconds())
time_to_find = int(input())

if time_to_find == '':
     time_to_find = None
     exit(0)

def time_from_seconds():

   time_output = time.strftime("%H Hours %M Minutes %S Seconds", time.gmtime(time_to_find)) 
   return time_output

print(time_from_seconds())

我做了一个文件,我在其中写道:

import timecount

结论是:

4
4
4
14644
4
00 Hours 00 Minutes 04 Seconds

前 3 行是变量sec min和的输入hour。第 4 行 - 秒的输出。第 5 行 - 输入秒。第 6 行 - 时间输出。如您所知,虽然我只导入了它,但整个模块都被执行了。

导入时间不输出任何东西

python
  • 1 个回答
  • 24 Views
Martin Hope
Андрей
Asked: 2022-08-06 02:31:26 +0000 UTC

在 php 7.4 中安装 intl 的问题

  • 0

我在 php.ini 中使用 OpenServer 面板,它看起来像这样:

extension_dir                = "c:/openserver/modules/php/PHP_7.4/ext"


;extension = intl

当您尝试取消注释时,当您重新启动服务器时,它会被注释掉。已安装 php_intl.dll。

php openserver
  • 1 个回答
  • 67 Views
Martin Hope
Андрей
Asked: 2022-06-14 03:45:12 +0000 UTC

如何使用python将数据写入csv?

  • 0

BeautifulSoup 上有一个简单的解析器,它看起来像这样:

url = 'https://www.avito.ru/sankt-peterburg/telefony/mobile-ASgBAgICAUSwwQ2I_Dc?cd=1&q=%D1%81%D0%BC%D0%B0%D1%80%D1%82%D1%84%D0%BE%D0%BD'
response = requests.get(url)
soup = BeautifulSoup(response.text, 'lxml')
quotes = soup.find_all('h3', class_='title-root-j7cja iva-item-title-_qCwt title-listRedesign-XHq38 title-root_maxHeight-SXHes text-text-LurtD text-size-s-BxGpL text-bold-SinUO')



for quote in quotes:
    print(quote.text)

如何将值写入quotesCSV?

python
  • 1 个回答
  • 10 Views
Martin Hope
Андрей
Asked: 2022-05-17 00:52:27 +0000 UTC

/etc/shadow 有什么哈希函数?

  • 0

Ubuntu 使用什么哈希/etc/shadow?

linux
  • 1 个回答
  • 10 Views
Martin Hope
Андрей
Asked: 2022-05-12 01:16:10 +0000 UTC

cfg grub 问题

  • 1

Linux 20.10 尝试登录 GRUB,初始尝试失败。检查的 Timeot/etc/default/grub 看起来像这样:

GRUB_TIMEOUT="0"

替换为

GRUB_TIMEOUT="5"

但这没有帮助。

完整的 cfg 如下所示:

GRUB_DEFAULT=0
GRUB_TIMEOUT_STYLE=hidden
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT="5"
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX=""
linux
  • 2 个回答
  • 10 Views

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    我看不懂措辞

    • 1 个回答
  • Marko Smith

    请求的模块“del”不提供名为“default”的导出

    • 3 个回答
  • Marko Smith

    "!+tab" 在 HTML 的 vs 代码中不起作用

    • 5 个回答
  • Marko Smith

    我正在尝试解决“猜词”的问题。Python

    • 2 个回答
  • Marko Smith

    可以使用哪些命令将当前指针移动到指定的提交而不更改工作目录中的文件?

    • 1 个回答
  • Marko Smith

    Python解析野莓

    • 1 个回答
  • Marko Smith

    问题:“警告:检查最新版本的 pip 时出错。”

    • 2 个回答
  • Marko Smith

    帮助编写一个用值填充变量的循环。解决这个问题

    • 2 个回答
  • Marko Smith

    尽管依赖数组为空,但在渲染上调用了 2 次 useEffect

    • 2 个回答
  • Marko Smith

    数据不通过 Telegram.WebApp.sendData 发送

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5