Try starting Jupyter Notebook ~ Esper training

Until Jupyter Notebook starts

--It is difficult to categorize this article ――I don't know what the problem is in the first place, so I can't decide the title or category first.

Imagine the environment

I could have imagined it because it was pasted in the image, is it jupyter as expected?

docker-compose.yml


version: '3'
services:
  jupyter:
    image: jupyter/scipy-notebook
    ports:
      - 10000:8888
    volumes:
      - $PWD:/home/jovyan/work
    command: start.sh jupyter lab --NotebookApp.token=''
$ docker-compose up

Go to http: // localhost: 10000 / and look at the console.

Try

I'd be happy if someone had the code when trying it, but I didn't have it so I hit it by hand

Source 1


data = {'name': ['Ryo', 'Kaori', 'Hideyuki', 'Hayato', 'Miki', 'Saeko'],
        'gender': ['M', 'F', 'M', 'M', 'F', 'F'],
        'height': [186, 168, 175, 210, 160, 163],
        'weight': [72, 47, 62, 90, None, numpy.NaN],
        'age': [30, 20, None, numpy.NaN, 23, 25],
        'size': ['L', 'M', 'L', 'XL', None, 'S']
        }

error


NameError: name 'numpy' is not defined

After modification 1


import numpy
data = {'name': ['Ryo', 'Kaori', 'Hideyuki', 'Hayato', 'Miki', 'Saeko'],
        'gender': ['M', 'F', 'M', 'M', 'F', 'F'],
        'height': [186, 168, 175, 210, 160, 163],
        'weight': [72, 47, 62, 90, None, numpy.NaN],
        'age': [30, 20, None, numpy.NaN, 23, 25],
        'size': ['L', 'M', 'L', 'XL', None, 'S']
        }

Try it 2

Source 2


size2int = {'S': 1, 'M': 2, 'L': 3, 'XL': 4}
df['size'] = df['size'].map(size2int)
df

error


NameError: name 'df' is not defined

Well, that's right

After modification 2


import pandas as pd
df = pd.DataFrame(data)
#size2int means size to int
size2int = {'S': 1, 'M': 2, 'L': 3, 'XL': 4}
df['size'] = df['size'].map(size2int)
df
スクリーンショット 2020-04-30 13.41.33.png

It's done. Why doesn't it work? Insufficient esper power.

Esper

The expectation is that I overwrote the size column once with size2int missing. After that, it is only NaN.

sample


size2int = {'S': 1, 'M': 2, 'L': 3, 'XL': 4}

Like

Then, let's try data → df again. Is something.

Really?

Fail once


import pandas as pd
df = pd.DataFrame(data)
size2int = {}
df['size'] = df['size'].map(size2int)
df

No matter how many times I do it


size2int = {'S': 1, 'M': 2, 'L': 3, 'XL': 4}
df['size'] = df['size'].map(size2int)
df

Can be reproduced for the time being

Add WIP Esper power

Summary

――Mostly you stumble where it doesn't really matter ――It is surprisingly important to create an environment where you can try it from the beginning ――Docker is convenient when you want to create an environment quickly. Because it is a code, you can pass it

Recommended Posts

Try starting Jupyter Notebook ~ Esper training
Try using Jupyter Notebook dynamically
Try running Jupyter Notebook on Mac
Try SVM with scikit-learn on Jupyter Notebook
Jupyter Notebook memo
Introducing Jupyter Notebook
Powerful Jupyter Notebook
Jupyter notebook password
Jupyter Notebook memo
Try a state-space model (Jupyter Notebook + IR kernel)
Try using conda virtual environment with Jupyter Notebook
Try Apache Spark on Jupyter Notebook (on local Docker
Try using Jupyter Notebook of Azure Machine Learning
Get started Jupyter Notebook
Monitor the training model with TensorBord on Jupyter Notebook
Try basic operations for Pandas DataFrame on Jupyter Notebook
3 Jupyter notebook (Python) tricks
[Cloud103] # 3 Jupyter Notebook again
Try clustering with a mixed Gaussian model on a Jupyter Notebook
Shortcut key for Jupyter notebook
Introduced Jupyter Notebook to CentOS 7
Using Graphviz with Jupyter Notebook
Display HTML in Jupyter notebook
Use pip with Jupyter Notebook
Multiprocessing error in Jupyter Notebook
[Super Basics] About jupyter Notebook
View PDF on Jupyter Notebook
homebrew, pyenv, anaconda, Jupyter Notebook
Play with Jupyter Notebook (IPython Notebook)
Try running Python with Try Jupyter
Run Jupyter Notebook on windows
How to use Jupyter Notebook
python3.8 venv environment jupyter notebook