pythonpandasmatplotlibquandl

Python use implicit argument on new class without pre constructing Object from class that inherits: pandas, Quandl, matplotlib, NumPy


I'm new to python as to artificial intelligence. I'm using matplotlib to plot the curve of data in a pandas dataframe that I get with Quandl. In examples, I'm seeing stuff like this:

import pandas as pd
import Quandl
import matplotlib.pyplot as plt
df = Quandl.get('WIKI/GOOGL')
df[['Adj. Close']].plot()
plt.show()

How does the xml or json returned from Quandl gets immediately converted into a pandas object (dataframe I guess).

Other than that, I want to know how is the pandas serie that I get from the dataframe able to be passed as an implicit argument to the .plot() method from another library (matplotlib) without even constructing an object from matplotlib that inherits the pandas serie class.

I mean how and why was I able to directly write pandas_series_object.plot() in df[['Adj. Close']].plot() instead of plotter.plot(df[['Adj. Close']])

Thanks in advance!!

If someone came here after watching sentdex's python machine learning series tutorial on youtube, that Question/Answer is just for it.


Solution

  • Okay so what Hampus Larsson said in the comment was part of the answer, Quandl.get returns a pandas dataframe and not xml nor json, at least for the python implementation of Quandl as cited on https://www.quandl.com/tools/python , It says:

    Quandl requires NumPy (v1.8 or above) and pandas (v0.14 or above) to work.

    For the other part of the question regarding matplotlib being called as such df[['Adj. Close']].plot(), I've found online on both websites of matplotlib and pandas that they extend each other with wrapper functions hard-coded in their libraries and that's why it works. References:

    On pandas website: https://pandas.pydata.org/pandas-docs/version/0.13/visualization.html

    On matplolib's website: https://matplotlib.org/thirdpartypackages/index.html#gui-applications