{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Items\n", "API to fetch and process the data." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from arche.readers.items import *" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## From Cloud" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "job_items = JobItems(key=\"381798/1/3\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "job_items.df.head()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## From DataFrame\n", "You can also create items from a pandas dataframe, meaning you can use its wonderful [DataFrame API](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.html).\n", "\n", "Note: raw items data can be different from pandas, especially around `NAN` and integer values - see https://pandas.pydata.org/pandas-docs/stable/user_guide/gotchas.html#support-for-integer-na" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "items = Items.from_df(pd.read_csv(\"https://raw.githubusercontent.com/scrapinghub/arche/master/docs/source/nbs/data/items_books_1.csv\"))" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "items.df.head(5)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## From Iterable\n", "As an alternative, an items iterable can be passed in" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "??Items.from_array" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "items = Items.from_array([{\"_key\": \"0\", \"title\": \"Universe\"}])" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "items.raw" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "items.df" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.2" }, "widgets": { "application/vnd.jupyter.widget-state+json": { "state": {}, "version_major": 2, "version_minor": 0 } } }, "nbformat": 4, "nbformat_minor": 4 }