LoginSignup
0
0

More than 1 year has passed since last update.

【環境構築】macOS Big Sur 11.6.1 + Dockerのpython containerにpandasをinstall

Posted at

会社貸与のMacBook Proに飲み物をこぼしてしまい動かなくなったので交換してもらった。:bow_tone1:
前のマシンにはPythonやらPandasやら使いたいライブラリーを直接インストールしていたので、環境のトラブルがあった場合に色々と面倒だった。今回は素直にDockerで環境構築して、いざとなればimage捨てて作り直せばいいやと思い、環境構築の手順をロギング。

pyhtonのcontainer実行できるようになったので、自分の仕事の効率化のために書いたpythonコード実行する環境を再構築する。
ということで、今回はpandsをinstall

前回までの記事
【環境構築】macOS Big Sur 11.6.1 にDockerをInstall
https://qiita.com/cocoapuff/items/e3eee747b1aeafa32037
【環境構築】macOS Big Sur 11.6.1 + Dockerでpython
https://qiita.com/cocoapuff/items/1daaf9e91b24bc3818ad

pandsをインストール

pythonのcontainerは動いている前提
自分macにはpipをinstallしていないので、間違ってMacのterminalで実行しても問題ないけど、cpntainer側のCLIで実行するよう気をつける

# pip3 install pandas

これだけです。

pandasを使ったpythonコードを実行してみる

pandasをimportして使えていることを確かめる簡単なコードを書いて実行してみる

pandas_test.py
import pandas as pd

df = pd.DataFrame(
        {
            'name':['itoh', 'saitoh'],
            'age':['20', '30']
        })

print(df)
# python ./pandas_test.py
     name age
0    itoh  20
1  saitoh  30

問題なく動いたので、pandasは使える

今日はここまで。
container内でコード書くの大変なのでVScodeで書けるようにしたい。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0