A memo to visually understand the axis of pandas.Panel

As a memorandum, I often forget the orientation of the axis of pandas.Panel.

Pass the list of tickers to the DataReader and a Panel will be returned.

python


import pandas_datareader.data as web
from datetime import datetime

tickers = ['AAPL', 'MSFT', 'ORCL']
sd = datetime(2016, 1, 1)
ed = datetime(2016, 1,10)

p = web.DataReader(tickers, "yahoo", sd, ed)    
print(p)
<class 'pandas.core.panel.Panel'>
Dimensions: 6 (items) x 5 (major_axis) x 3 (minor_axis)
Items axis: Open to Adj Close
Major_axis axis: 2016-01-04 00:00:00 to 2016-01-08 00:00:00
Minor_axis axis: AAPL to ORCL

When you access the Panel like this,

d = p['Open']
print(d)

This kind of data will be returned.

                  AAPL       MSFT       ORCL
Date                                        
2016-01-04  102.610001  54.320000  36.009998
2016-01-05  105.750000  54.930000  35.860001
2016-01-06  100.559998  54.320000  35.500000
2016-01-07   98.680000  52.700001  35.250000
2016-01-08   98.550003  52.369999  35.130001

In other words, in the figure,

panel2.png

By doing this, it is also possible to retrieve the value of a specific cell from the Panel with Series.

s = p['Open'][:1]['AAPL']
print(s)
Date
2016-01-04    102.610001
Freq: D, Name: AAPL, dtype: float64

Recommended Posts

A memo to visually understand the axis of pandas.Panel
A memo explaining the axis specification of axis
[python] A note that started to understand the behavior of matplotlib.pyplot
How to calculate the volatility of a brand
I didn't understand the Resize of TensorFlow so I tried to summarize it visually.
A memo connected to HiveServer2 of EMR with python
I want to fully understand the basics of Bokeh
Steps to calculate the likelihood of a normal distribution
14 quizzes to understand the surprisingly confusing scope of Python
Python Note: The mystery of assigning a variable to a variable
A memo on how to overcome the difficult problem of capturing FX with AI
A memo of misunderstanding when trying to load the entire self-made module with Python3
How to increase the axis
[Ubuntu] How to delete the entire contents of a directory
Make the display of Python module exceptions easier to understand
I made a function to check the model of DCGAN
A memo about the behavior of bowtie2 during multiple hits
How to develop in a virtual environment of Python [Memo]
How to find the scaling factor of a biorthogonal wavelet
[End of 2020] A memo to start using AWS CLI (Version 2)
Is there a secret to the frequency of pi numbers?
How to connect the contents of a list into a string
A story about porting the code of "Try and understand how Linux works" to Rust
A memo that reproduces the slide show (gadget) of Windows 7 on Windows 10.
How to determine the existence of a selenium element in Python
A memo to move Errbot locally
A story that struggled to handle the Python package of PocketSphinx
Conditional branch due to the existence of a shell script file
Understand the contents of sklearn's pipeline
How to check the memory size of a variable in Python
[Introduction to StyleGAN] I played with "The Life of a Man" ♬
[Go] Create a CLI command to change the extension of the image
How to check the memory size of a dictionary in Python
How to find the memory address of a Pandas dataframe value
How to output the output result of the Linux man command to a file
[Python3] Define a decorator to measure the execution time of a function
How to get the vertex coordinates of a feature in ArcPy
How to use machine learning for work? 01_ Understand the purpose of machine learning
A command to easily check the speed of the network on the console
Create a function to get the contents of the database in Go
Supplement to the explanation of vscode
The story of writing a program
[NNabla] How to remove the middle tier of a pre-built network
[Python] A simple function to find the center coordinates of a circle
[Python] A program that rotates the contents of the list to the left
Understand the number of input / output parameters of a convolutional neural network
A memo to simply use the illuminance sensor TSL2561 with Raspberry Pi 2
A memo for utilizing the unit test mechanism KUnit of the Linux kernel
Have Alexa run Python to give you a sense of the future
[Python] A program that calculates the number of socks to be paired
Various methods to numerically create the inverse function of a certain function Introduction
[Introduction to Python] How to sort the contents of a list efficiently with list sort
[Linux] Command to get a list of commands executed in the past
Semi-automatically generate a description of the package to be registered on PyPI
I want to sort a list in the order of other lists
[NNabla] How to add a quantization layer to the middle layer of a trained model
How to put a line number at the beginning of a CSV file
How to create a wrapper that preserves the signature of the function to wrap
Allow Slack to notify you of the end of a time-consuming program process
Python code to determine the monthly signal of a relative strength investment
I made a program to check the size of a file in Python