おお、deepseek-coder-v2って賢い。
公開 2024/07/04 13:25
最終更新 -
引き続き、「カレントフォルダの"world_population.csv"を参照し、人口が最大の国名を一つ表示しなさい。」ネタ。

deepseek-coder-v2というのがollamaに登録されていたので使用してみた。

以下、流れそのまま。
-----------------------------
> カレントフォルダの"world_population.csv"を参照し、人口が最大の国名を一つ表示しなさい。

Plan

1 Load the "world_population.csv" file.
2 Read and process the data to find the country with the maximum population.
3 Display the name of the country with the highest population.

Step 1: Load the CSV File

I will use Python to load the CSV file named "world_population.csv".


================================
import pandas as pd

# Load the CSV file
df = pd.read_csv('world_population.csv')
================================

Next, I will proceed to Step 2 of the plan, which is to read and process the data to find the country with the maximum population.

Step 2: Find the Country with the Maximum Population

Now that we have loaded the CSV file into a DataFrame using pandas in Python, we need to identify the country with the highest population.


================================
# Assuming 'Population' is the column name for population data
max_population = df['Population'].max()
country_with_max_pop = df[df['Population'] == max_population]['Country'].values[0]
================================

---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
File ~\miniconda3\envs\oi\Lib\site-packages\pandas\core\indexes\base.py:3805, in Index.get_loc(self, key)
3804 try:
-> 3805 return self._engine.get_loc(casted_key)
3806 except KeyError as err:

File index.pyx:167, in pandas._libs.index.IndexEngine.get_loc()

File index.pyx:196, in pandas._libs.index.IndexEngine.get_loc()

File pandas\\_libs\\hashtable_class_helper.pxi:7081, in pandas._libs.hashtable.PyObjectHashTable.get_item()

File pandas\\_libs\\hashtable_class_helper.pxi:7089, in pandas._libs.hashtable.PyObjectHashTable.get_item()

KeyError: 'Population'

The above exception was the direct cause of the following exception:
---------------------------------------------------------------------------
The error indicates that there is no column named "Population" in the DataFrame. This means the CSV file might not
have a column labeled as "Population." To resolve this issue, I will first check the headers of the CSV file to
identify the correct column name for population data.

Step 2 (Revised): Identify the Correct Column Name and Find the Country with the Maximum Population

Let's inspect the columns in the DataFrame to find out which one corresponds to population data.

===================================
# Check the headers of the DataFrame
print(df.columns)
===================================

---------------------------------------------------------------------------
Index(['Rank', 'CCA3', 'Country/Territory', 'Capital', 'Continent',
'2022 Population', '2020 Population', '2015 Population',
'2010 Population', '2000 Population', '1990 Population',
'1980 Population', '1970 Population', 'Area (sq km)',
'Density (per sq km)', 'Growth Rate', 'World Population Percentage'],
dtype='object')
---------------------------------------------------------------------------

The output indicates that the DataFrame contains several columns. From the list provided['Rank', 'CCA3',
'Country/Territory', 'Capital', 'Continent', '2022 Population', '2020 Population', '2015 Population', '2010 Population', '2000 Population', '1990 Population', '1980 Population', '1970 Population', 'Area (sq km)', 'Density (per sq km)', 'Growth Rate', 'World Population Percentage']`), the column labeled'2022 Population' seems to be the one that represents population data.
Next, I will proceed to find the country with the maximum population using this identified column.

===================================
# Assuming '2022 Population' is the correct column for population data
max_population = df['2022 Population'].max()
country_with_max_pop = df[df['2022 Population'] == max_population]['Country/Territory'].values[0]
print(f"The country with the maximum population is {country_with_max_pop}.")
===================================
---------------------------------------------------------------------------
The country with the maximum population is China.
---------------------------------------------------------------------------

This output means that based on the data in the DataFrame, the country with the highest population for the year 2022 is China. As there doesn't seem to be any further questions from the user and the task appears to be complete, I will consider this task concluded. If you have any other tasks or questions, please let me know!

最初のプロンプト以外は、pythonコードの実行許可を与えるだけでした。
エラーがどうして発生したのかを理解できるLLMがあっても、そこからどうすれば適切な解を得られるかまでを判断するのは結構難しいようですが、deepseek-coder-v2は難なくやってのけました。

(Llama3 8bでも3回試しましたが、自力で解決できませんでした。一応、修正は受け付けますので解答を得ることはできます。知識が豊富でも賢く見えないっていうのが、こういうことなんですよね。)
最近の記事
おそらくこれがサブスク(Google AI Plus)の恩恵
Google AI Plusに課金して、はじめてAntigravityを使用した時。 おお、これが課金した効果かと感じた。 無課金のとき、Anti…
2026/02/11 08:44
Google AI Plusに乗り換えた
Googleのクラウドストレージサービス(Google Drive)を増量するだけの名目でGoogle One(月額290円)に加入していたのだけれども、…
2026/01/29 09:22
旧PCでLinuxは動くが...(というよりCore i3の罠?)
ZorinOS18、若干貧弱なPCでも快適に使えるので、結構重宝しているんだけれども、環境を整えて本格的に使おうとしたら挫折した話…
2026/01/27 08:43
AIに議席数予測させてみた:2026年衆院選
今回はFelo、Gemini(Gemini3 Fast)、Gemini Deep Research(Gemini3 Fast)、Perplexity。 ただし、中道改革連合の支持率が出て…
2026/01/22 16:41
これは確かに不満が出るわ。Inspiron 15 3525
なんか、使っている人が不満そうなんだけど、どう不満なのか言えないみたいな微妙なパソコン。 でも、ちょっと触ってみて、…
2026/01/20 17:52
ちょっと困っていた問題が解決した話
pythonを使ってRPA的な処理を作成しようとするとき、重宝するのがSelenium。 2025年7月頃から困ってたことが、最新リリース向…
2026/01/13 13:57
Ctrl+Wが恨めしいと思った日
社長が使わなくなったからってHHKB Professional Hybridをくれた。 (ちなみに社長はHHKB Studio(墨)を使ってる。キートップ…
2026/01/13 12:07
ZorinOSを入れてみた
Chrome OS Flexを旧型PCに入れていたんだけど、どうもデスクトップがすっきりし過ぎて落ち着かない。 いや、汚いのが良いとは…
2025/12/19 14:24
マイクロソフトは劣化が著しい
新しいパソコンが届いたのでセットアップしようとして、サーバ上の共有フォルダを開こうとしたら、「拡張エラー」??? エ…
2025/12/16 11:29
意外と使えそうなOnlyOffice
(申し訳ない、支離滅裂な駄文です。) Windows環境で事務作業をするならExcelは必須と思う。 企業で使うなら、MS Officeプ…
2025/12/09 09:13
Antigravity便利
できることが多いと使いこなすまでの苦労が多いのが困る。 というのは冗談。 機能が多くてもわからなければ使わなくていいし…
2025/12/03 09:00
Google Antigravityを入れた
Google Antigravityを使ってみた。Gemini Code AssistのAgent modeがオンになっているVSCodeとどう違うのかよくわからん。Gemin…
2025/11/24 17:38
ある意味安直な高速化、だけど人力では経験が必要な、だからLLM
作業量が大きくて時間のかかる集計処理。 pythonでやっているんだが、これはGoとかで書き直さなきゃいけないかなぁ... と…
2025/11/18 15:19
Github Copilot無料枠は月間縛りつらいが、Geminiがある
Github CopilotでGPT-5miniとかよりも、Claude Haiku 4.5がありがたいというネタもチャットクオータの壁には勝てない。(ただし…
2025/11/18 13:21
コードの変更はClaude系が強い
Gemini Code Assistは便利ということで愛用してきたわけだが、処理内容を変更せずにリファクタリングさせようとするとGithub Co…
2025/11/11 16:36
Gemini Code AssistのAgentモードが途中で停止すると...
Gemini Code Assistにリファクタリングをさせていたところ、原因不明で停止してしまった。 今日、実施していた感じでは、いく…
2025/10/24 16:27
ワイヤレスマウスの不調
会社で使用しているワイヤレスマウスが動きが悪いということで、動作確認をしてみた。 センサで使用している赤色LEDの様子を見…
2025/10/20 11:38
WiFiルーターを変更
安いのでTP-linkの‎Archer AX3000を導入した。 インターネットプロバイダーからレンタルでつかっていたんだけれども、思うとこ…
2025/10/14 11:09
恣意的という言葉は嫌い
「恣意的」その時々の思いつきで物事を判断するさま。 というのが、まず出てくるんだけれども、weblio辞書によれば、「意図…
2025/10/10 10:19
AIのせいで新人の仕事がなくなって、就職難とのお話
ここのところ、ネット記事で読むことが多いので思ったこと。 生成AIとかLLMとか、ChatGPTに代表されるようなAIが賢くなって…
2025/10/01 15:54
もっと見る
タグ
AI(38)
IT(20)
雑感(7)
IoT(6)
AI,(5)
IT,(5)
愚痴(5)
日記(3)
RPA(2)
アニメ(2)
ChatGPTで遊ぶ(1)
Windows11(1)
自動処理(1)
もっと見る