日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

python编写代码时零_python – KeyError:运行打包代码时为0L

發(fā)布時間:2023/12/2 python 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python编写代码时零_python – KeyError:运行打包代码时为0L 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

我有一個名為rra.py的腳本,它具有以下skelton結(jié)構(gòu):

usn=""

usnl=[]

from bs4 import BeautifulSoup

import re

import asys

import glob

import os

import sys

import sys

def inputIndex():

#some processsing

def getval():

#some processing

def parsehtml():

#some processsing

def ret():

#some processing

def main():

inputIndex()

ret()

parsehtml()

getval()

print "watsuup"

asys.Compavg()

asys.compSub()

print "nearly done"

return 0

if __name__ == '__main__':

inputIndex()

main()

asys.Compavg()

asys.compSub()

我在上面的腳本rra.py中導入了另一個腳本asys.py,其中包含以下內(nèi)容.

import pandas as pd

import numpy as np

import matplotlib.pyplot as plt

from scipy import stats

import statsmodels.api as sm

from numpy.random import randn

import matplotlib as mpl

import seaborn as sns

sns.set_color_palette("deep", desat=.6)

mpl.rc("figure", figsize=(8, 4))

def Compavg():

data=Total()

markMax=[]

markAvg=[]

N = 5

ind = np.arange(N)

width = 0.35

fig = plt.figure()

ax = fig.add_subplot(111)

markMax.extend((data["Total"].max(),data["Total.1"].max(),data["Total.2"].max(),data["Total.3"].max(),data["Total.4"].max()))

markAvg.extend((data["Total"].mean(),data["Total.1"].mean(),data["Total.2"].mean(),data["Total.3"].mean(),data["Total.4"].mean()))

rects1 = ax.bar(ind, markMax, width, color='black')

rects2 = ax.bar(ind+width, markAvg, width, color='green')

ax.set_xlim(-width,len(ind)+width)

ax.set_ylim(0,120)

ax.set_ylabel('Marks')

ax.set_title('Max, Mean and Your Marks')

xTickMarks = ['Subject'+str(i) for i in range(1,6)]

ax.set_xticks(ind+width)

xtickNames = ax.set_xticklabels(xTickMarks)

plt.setp(xtickNames, rotation=10, fontsize=10)

ax.legend( (rects1[0], rects2[0]), ('Max', 'Mean') )

plt.show()

print "finished reading 1"

def compSub():

#max_data = np.r_[data["Total"]].max()

#bins = np.linspace(0, max_data, max_data + 1)

data=Total()

print data['Total']

plt.hist(data['Total'],linewidth=0, alpha=.7)

plt.hist(data['Total.1'],linewidth=0,alpha=.7)

plt.hist(data['Total.2'],linewidth=0,alpha=.7)

plt.hist(data['Total.3'],linewidth=0,alpha=.7)

plt.hist(data['Total.4'],linewidth=0,alpha=.7)

plt.title("Total marks Histogram")

plt.xlabel("Value")

plt.ylabel("Frequency")

plt.show()

print "finished reading 2"

def Total():

print "going to read"

data=pd.read_csv("output11cs.csv")

df3=data[['Total','Total.1','Total.2','Total.3','Total.4','Total.5','Total.6','Total.7']]

data["Main Total"]=df3.sum(axis=1)

data = data.dropna()

data.reset_index(drop=True)

return data

#compSub()

#Compavg()

當我通過使用python rra.py執(zhí)行virtualenv之外的rra.py(甚至在virtualenv內(nèi))時,它執(zhí)行完美并繪制asys.py中給出的圖形和直方圖.

然后我創(chuàng)建了一個’setup.py’文件來打包它,如下所示:

from ez_setup import use_setuptools

use_setuptools()

from setuptools import setup, find_packages

from setuptools.command.test import test as TestCommand

import vturra

import sys

class PyTest(TestCommand):

def finalize_options(self):

TestCommand.finalize_options(self)

self.test_args = []

self.test_suite = True

def run_tests(self):

import pytest

errcode = pytest.main(self.test_args)

sys.exit(errcode)

setup(name="vturra",

version=vturra.__version__,

license='Apache Software License',

tests_require=['pytest'],

install_requires=['matplotlib>=1.2.1',

'pandas',

'numpy',

'scipy',

'beautifulsoup',

'requests',

'patsy',

'seaborn==0.2.1',

'BeautifulSoup4'

],

cmdclass={'test': PyTest},

description="Downloads results from VTU website and analyzes the result",

long_description=open('README.md').read(),

author="Muhammed Thaha",

author_email='mthaha1989@gmail.com',

download_url='https://github.com/stormvirux/vturra',

packages=find_packages(exclude='tests'),

package_data={'vturra': ['data/*.xml']},

include_package_data=True,

platforms='any',

test_suite='vturra.test.test_vturra',

classifiers = [

'Programming Language :: Python',

'Development Status :: 1 - Beta',

'Natural Language :: English',

'Environment :: Web Environment',

'Intended Audience :: Developers',

'License :: OSI Approved :: Apache Software License',

'Operating System :: OS Independent',

'Topic :: Internet :: WWW/HTTP :: Dynamic Content',

],

extras_require={

'testing': ['pytest'],

},

entry_points={

"console_scripts": [

"vturra=vturra.rra:main"

#"pip%s=pip:main" % sys.version[:1],

#"pip%s=pip:main" % sys.version[:3],

],

}

)

我在virtualenv中使用python setup.py install安裝了軟件包,安裝完成后一切正常.現(xiàn)在,當我執(zhí)行包vturra時,我收到以下錯誤:

Traceback (most recent call last):

File "asys.py", line 65, in

compSub()

File "asys.py", line 46, in compSub

plt.hist(data['Total'],linewidth=0, alpha=.7)

File "/home/storm/Documents/lol/local/lib/python2.7/site-packages/matplotlib/pyplot.py", line 2827, in hist

stacked=stacked, **kwargs)

File "/home/storm/Documents/lol/local/lib/python2.7/site-packages/matplotlib/axes.py", line 8249, in hist

if isinstance(x, np.ndarray) or not iterable(x[0]):

File "/home/storm/Documents/lol/local/lib/python2.7/site-packages/pandas/core/series.py", line 491, in __getitem__

result = self.index.get_value(self, key)

File "/home/storm/Documents/lol/local/lib/python2.7/site-packages/pandas/core/index.py", line 1032, in get_value

return self._engine.get_value(s, k)

File "index.pyx", line 97, in pandas.index.IndexEngine.get_value (pandas/index.c:2661)

File "index.pyx", line 105, in pandas.index.IndexEngine.get_value (pandas/index.c:2476)

File "index.pyx", line 149, in pandas.index.IndexEngine.get_loc (pandas/index.c:3215)

File "hashtable.pyx", line 382, in pandas.hashtable.Int64HashTable.get_item (pandas/hashtable.c:6450)

File "hashtable.pyx", line 388, in pandas.hashtable.Int64HashTable.get_item (pandas/hashtable.c:6394)

KeyError: 0L

但是,如果我在main()中注釋掉函數(shù)調(diào)用asys.compSub(),它的工作沒有任何錯誤.

UPDATE

該函數(shù)作為virtualenv之外的獨立腳本執(zhí)行時效果很好,但在virtualenv中你會得到上述錯誤.

我相信這是virtualenv的一個問題呢?

最佳答案 終于解決了.這是最新版本的thepandas和matplotlib之間的問題.

與擁有0.13.0的virtualenv相比,Global System pandas版本為0.10.所以我在virtualenv降級到0.10.0.

現(xiàn)在它的工作完美.

基本上它與matplotlib和pandas的API不兼容> = 0.13. plt.hist與系列目前將面臨這個問題.

所以要么使用數(shù)據(jù)[‘Total.1’].hist()

或者傳入值plt.hist(data [‘Total.1’].values,….)

或?qū)andas降級到小于0.13的版本.

總結(jié)

以上是生活随笔為你收集整理的python编写代码时零_python – KeyError:运行打包代码时为0L的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 综合色网站 | 国产高清在线观看视频 | www亚洲视频| 天天色宗合| 久久网页 | 黑人一级 | 狠狠人妻久久久久久综合蜜桃 | 中文字幕国产在线 | 日本在线成人 | av伊人久久 | 国产精品国产一区 | 免费视频毛片 | 日韩精品视频在线播放 | 91欧美成人 | www.-级毛片线天内射视视 | 男生c女生 | 欧美日韩五月天 | 波多野结衣免费在线视频 | 日韩av中文 | 伊人色网 | 久久福利影视 | 一级片免费在线观看 | 欧美视频性 | 日韩少妇毛片 | 人人爽爽爽 | 日本少妇喷水视频 | 超级碰在线视频 | 日韩精品一二三四 | 奇米综合网| 91手机视频 | 国产精品一区在线播放 | 日本女优在线看 | 成人午夜视频一区二区播放 | 国产a黄| www色婷婷 | 欧美一区二区三区公司 | 黄色免费在线看 | 欧洲亚洲一区二区三区 | 欧美日韩亚洲精品内裤 | 中文字幕在线视频一区二区 | 国产精品嫩草av | 免费福利视频在线观看 | 欧美a在线视频 | 91色影院 | 人人澡人人插 | 日本专区在线 | 国产ts丝袜人妖系列视频 | 国产91免费观看 | 国产露脸国语对白在线 | 牛牛视频在线观看 | 影音av在线 | 国产精品100 | 亚洲AV无码久久精品国产一区 | 五月天小说网 | 国产无码精品在线观看 | 久久色av | 成人免费网站在线观看 | 用力使劲高潮了888av | 91免费版在线 | 强伦人妻一区二区三区 | 欧洲精品一区二区 | 成人性视频网 | 精品成人av一区二区三区 | 少妇偷人精品无码人妻 | 日韩毛片高清在线播放 | av综合色 | 亚洲区视频在线观看 | 亚洲色图综合在线 | 国产aⅴ片 | 91在线精品李宗瑞 | 大学生高潮无套内谢视频 | 欧美大尺度做爰啪啪床戏明星 | 超碰免费97 | 久久99久久久久久 | 性爱动漫 | 一本大道东京热无码 | 99热这里精品| 依人在线| 91观看视频 | av无限看 | 天堂中文在线视频 | 国产又粗又长又硬免费视频 | 亚洲最大的黄色网 | 500部大龄熟乱视频 亚洲乱码精品 | 午夜小视频在线播放 | 在线免费观看黄网 | 国模人体一区二区 | 国产黄站 | 麻豆影视大全 | 自宅警备员在线观看 | 国产一级片免费视频 | 黄色网址你懂得 | 国产精品福利在线播放 | 中文字幕精品久久久久人妻红杏1 | 公肉吊粗大爽色翁浪妇视频 | 二区久久| 成人av网站在线播放 | 激情五月婷婷综合网 | 奇米影视在线播放 |