タグ付けされた質問 「python」

Pythonは、マルチパラダイム、動的型付け、多目的プログラミング言語です。これは、学習、理解、使用が迅速で、クリーンで統一された構文を適用できるように設計されています。Python 2は2020年1月1日をもって正式にサポートされなくなりました。それでも、バージョン固有のPythonの質問については、[python-2.7]または[python-3.x]タグを追加します。Pythonのバリアントまたはライブラリ(Jython、PyPy、Pandas、Numpyなど)を使用する場合は、タグに含めてください。

3
Seaborn Barplotの軸にラベルを付ける
次のコードを使用して、Seabornバープロットに自分のラベルを使用しようとしています。 import pandas as pd import seaborn as sns fake = pd.DataFrame({'cat': ['red', 'green', 'blue'], 'val': [1, 2, 3]}) fig = sns.barplot(x = 'val', y = 'cat', data = fake, color = 'black') fig.set_axis_labels('Colors', 'Values') ただし、次のエラーが発生します。 AttributeError: 'AxesSubplot' object has no attribute 'set_axis_labels' 何ができますか?

10
データフレームをcsvに直接s3 Pythonに保存
新しいCSVファイルにアップロードしたいpandas DataFrameがあります。問題は、s3に転送する前にファイルをローカルに保存したくないことです。データフレームを直接s3に書き込むためのto_csvのような方法はありますか?私はboto3を使用しています。 ここに私がこれまでに持っているものがあります: import boto3 s3 = boto3.client('s3', aws_access_key_id='key', aws_secret_access_key='secret_key') read_file = s3.get_object(Bucket, Key) df = pd.read_csv(read_file['Body']) # Make alterations to DataFrame # Then export DataFrame to CSV through direct transfer to s3

10
Pytorchのモデルの概要
次のように、Kerasのmodel.summary()メソッドのようにPyTorchでモデルの概要を印刷できますか? Model Summary: ____________________________________________________________________________________________________ Layer (type) Output Shape Param # Connected to ==================================================================================================== input_1 (InputLayer) (None, 1, 15, 27) 0 ____________________________________________________________________________________________________ convolution2d_1 (Convolution2D) (None, 8, 15, 27) 872 input_1[0][0] ____________________________________________________________________________________________________ maxpooling2d_1 (MaxPooling2D) (None, 8, 7, 27) 0 convolution2d_1[0][0] ____________________________________________________________________________________________________ flatten_1 (Flatten) (None, 1512) 0 maxpooling2d_1[0][0] ____________________________________________________________________________________________________ dense_1 (Dense) (None, 1) …
125 python  pytorch 

13
「UserWarning:Matplotlibは現在非GUIバックエンドであるaggを使用しているため、図を表示できません。」Pycharmにpyplotで図形をプロットするとき
私はpyplotを使用して簡単なグラフをプロットしようとしています。例: import matplotlib.pyplot as plt plt.plot([1,2,3],[5,7,4]) plt.show() しかし、図は表示されず、次のメッセージが表示されます。 UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure. 私はいくつかの場所で、以下を使用してmatplotlibの構成を変更する必要があることを確認しました。 import matplotlib matplotlib.use('TkAgg') import matplotlib.pyplot as plt これを実行しましたが、モジュールが見つからないため、エラーメッセージが表示されました。 ModuleNotFoundError: No module named 'tkinter' 次に、pip install tkinter(仮想環境内で)を使用して「tkinter」をインストールしようとしましたが、見つかりません: Collecting tkinter Could not find a version that satisfies …



2
Flaskの「エンドポイント」とは何ですか?
フラスコのドキュメント番組: add_url_rule(*args, **kwargs) Connects a URL rule. Works exactly like the route() decorator. If a view_func is provided it will be registered with the endpoint. endpoint – the endpoint for the registered URL rule. Flask itself assumes the name of the view function as endpoint 「エンドポイント」とはどういう意味ですか?
124 python  flask 

6
NumPy配列のすべてのセルでの関数の効率的な評価
与えられたnumpyのの配列A、適用する最速/最も効率的な方法何同じ機能を、Fに、すべてのセル? A(i、j)にf(A(i、j))を割り当てると仮定します。 関数fにはバイナリ出力がないため、マスク()演算は役に立ちません。 「すべてのセルを通る」「明白な」二重ループ反復は最適なソリューションですか?

10
AWS EC2インスタンスにPython 3をインストールするにはどうすればよいですか?
AWS EC2インスタンスにpython 3.xをインストールしようとしています: sudo yum install python3 動作しません: No package python3 available. 私はググってみて、この問題を抱えている他の人を見つけることができないので、私はここで尋ねます。手動でダウンロードしてインストールする必要がありますか?


6
Linux上のpythonの2つのバージョン。2.7をデフォルトにする方法
私のlinuxboxには2つのバージョンのpythonがあります。 $python Python 2.6.6 (r266:84292, Jul 10 2013, 22:48:45) [GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> $ /usr/local/bin/python2.7 Python 2.7.3 (default, Oct 8 2013, 15:53:09) [GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2 Type "help", "copyright", "credits" or "license" …
124 python  linux  centos 

2
初期データの順序を保持するようにコンストラクターを使用してOrderedDictを初期化する正しい方法は?
初期データの順序を保持するように順序付き辞書(OD)を初期化する正しい方法は何ですか? from collections import OrderedDict # Obviously wrong because regular dict loses order d = OrderedDict({'b':2, 'a':1}) # An OD is represented by a list of tuples, so would this work? d = OrderedDict([('b',2), ('a', 1)]) # What about using a list comprehension, will 'd' preserve the order of 'l' …

10
PythonでWSDL(SOAP)Webサービスを使用するにはどうすればよいですか?
PythonでWSDL SOAPベースのWebサービスを使用したい。私はDive Into Pythonコードを調べましたが、SOAPpyモジュールはPython 2.5では機能しません。 私が使って試してみました泡一部が動作しますが、特定の種類(suds.TypeNotFound:タイプ見つかりません:「アイテム」)で休憩。 私もクライアントを見ましたが、これはWSDLをサポートしていないようです。 そして、私が見てきましたZSIが、それは非常に複雑に見えます。誰かがそのためのサンプルコードを持っていますか? WSDLはhttps://ws.pingdom.com/soap/PingdomAPI.wsdlであり、PHP 5 SOAPクライアントで正常に動作します。

7
Pythonがsys.pathのディレクトリにある共有オブジェクトを見つけられないのはなぜですか?
インポートしようとしていpycurlます: $ python -c "import pycurl" Traceback (most recent call last): File "<string>", line 1, in <module> ImportError: libcurl.so.4: cannot open shared object file: No such file or directory 現在、にlibcurl.so.4あり/usr/local/libます。ご覧のとおり、これは次の場所にありsys.pathます。 $ python -c "import sys; print(sys.path)" ['', '/usr/local/lib/python2.5/site-packages/setuptools-0.6c9-py2.5.egg', '/usr/local/lib/python25.zip', '/usr/local/lib/python2.5', '/usr/local/lib/python2.5/plat-linux2', '/usr/local/lib/python2.5/lib-tk', '/usr/local/lib/python2.5/lib-dynload', '/usr/local/lib/python2.5/sitepackages', '/usr/local/lib', '/usr/local/lib/python2.5/site-packages'] どんな助けでも大歓迎です。

3
URLパラメータへのPython辞書
Python辞書を文字列に変換してURLパラメータとして使用しようとしています。これを行うには、より良い、よりPython的な方法があると私は確信しています。それは何ですか? x = "" for key, val in {'a':'A', 'b':'B'}.items(): x += "%s=%s&" %(key,val) x = x[:-1]

弊社のサイトを使用することにより、あなたは弊社のクッキーポリシーおよびプライバシーポリシーを読み、理解したものとみなされます。
Licensed under cc by-sa 3.0 with attribution required.