#18 各産業の廃棄物発生量Wxを格納するデータフレームの作成/Creating a DataFrame to Store Waste Generation (Wx) by Industry

An English translation of this article is provided at the bottom of the page.

今回は、推計する各産業の廃棄物発生量Wxを格納するデータフレームを作成します。

Wxの算出式は、下記のようになります。

以前に作成した、重量単価一覧表のデータフレームdf_price_per_tonを利用します。

# 廃棄物発生量の計算結果を格納するデータフレームを作成
df_waste = df_price_per_ton.rename(columns={'重量単価':'廃棄物発生量'})
df_waste['廃棄物発生量'] = 0
df_waste = df_waste.drop(index=['4111', '4112', '4121', '4131', '4191'])

1行目で、renameメソッドで、列名「重量単価」を「廃棄物発生量」に変更します。

2行目で、列「廃棄物発生量」の数値を全て0で初期化しています。

3行目で、不要な産業の行を削除しています。

ついでに、計算過程で算出している、「投入分」、「産出分」、「燃料使用分」も格納することにします。

なので、コードを以下のように追記、変更しました。

# 廃棄物発生量の計算結果を格納するデータフレームを作成
df_waste = df_price_per_ton.rename(columns={'重量単価':'廃棄物発生量'})
df_waste['廃棄物発生量'] = 0
df_waste = df_waste.drop(index=['4111', '4112', '4121', '4131', '4191'])
df_waste['投入分'] = 0
df_waste['産出分'] = 0
df_waste['燃料使用分'] = 0
df_waste

English translation part is here.

In this section, we will create a DataFrame to store the estimated waste generation volume (Wx) for each industry.

The formula for calculating Wx is as follows:

We will use the previously created DataFrame df_price_per_ton, which contains the unit price per weight list.

# Create a DataFrame to store the calculation results for waste generation
df_waste = df_price_per_ton.rename(columns={'重量単価':'廃棄物発生量'})
df_waste['廃棄物発生量'] = 0
df_waste = df_waste.drop(index=['4111', '4112', '4121', '4131', '4191'])

In the first line, the rename method is used to change the column name from "重量単価" to "廃棄物発生量".

In the second line, all values in the "廃棄物発生量" column are initialized to 0.

In the third line, rows for unnecessary industries are removed.

In addition, we will also store the intermediate values calculated during the process: "投入分" (Inputs), "産出分" (Outputs), and "燃料使用分" (Fuel Consumption).

Therefore, the code has been updated and modified as follows:

# Create a DataFrame to store the calculation results for waste generation
df_waste = df_price_per_ton.rename(columns={'重量単価':'廃棄物発生量'})
df_waste['廃棄物発生量'] = 0
df_waste = df_waste.drop(index=['4111', '4112', '4121', '4131', '4191'])
df_waste['投入分'] = 0
df_waste['産出分'] = 0
df_waste['燃料使用分'] = 0
df_waste

Follow me!

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です