task_boiler
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
task_boiler [2022/03/18 22:57] – raju | task_boiler [2024/01/22 22:59] – [Issue] raju | ||
---|---|---|---|
Line 4: | Line 4: | ||
Start the first heading with " | Start the first heading with " | ||
- | ===== convert a dictionary of dataframes to a big dataframe | + | ===== blocked by barrons |
- | ==== Task ==== | + | ==== Issue ==== |
- | Given a dictionary where the keys are strings and values are dataframes, we want to create an expanded | + | barrons.com is giving |
- | dataframe where the keys go into a column of their own. For example, given | + | |
< | < | ||
- | {' | + | You have been blocked. |
- | 0 202102 | + | |
- | 1 202105 | + | Why? |
- | 2 202108 | + | Something about the behaviour of the browser has caught our |
- | 3 202111 | + | attention. |
- | ' | + | |
- | 0 202104 | + | There are various possible explanations for this: |
- | 1 202107 | + | * You are browsing and clicking at a speed much faster than |
- | 2 202110 | + | |
- | 3 202201 | + | * Something is preventing JavaScript from working on your |
- | </ | + | |
- | We want | + | * There is a robot on the same network (IP WW.XX.YY.ZZ) as you. |
- | < | + | |
- | ticker | + | Having problems accessing the site? Submit feedback. |
- | 0 | + | ID: a-b-c-d-e |
- | 1 | + | |
- | 2 | + | |
- | 3 | + | |
- | 4 | + | |
- | 5 | + | |
- | 6 | + | |
- | 7 | + | |
</ | </ | ||
==== Solution ==== | ==== Solution ==== | ||
- | <code> | + | Click on the extensions button in the top right |
- | pd.concat(dict_df, | + | -> Bypass Paywalls Clean -> settings button -> Options |
- | </code> | + | -> scroll down to "BPC settings" |
- | Using the example above | + | -> check " |
- | <code> | + | -> Save |
- | $ ipython | + | |
- | Python 3.6.12 |Anaconda, Inc.| (default, Sep 9 2020, 00:29:25) [MSC v.1916 64 bit (AMD64)] | + | |
- | Type ' | + | |
- | IPython 7.16.1 | + | |
- | In [1]: | + | ==== System Information ==== |
- | import pandas as pd | + | |
- | costco_earnings | + | |
- | | + | * OS: Windows 10 Enterprise |
- | ' | + | |
- | }) | + | |
- | costco_earnings | + | |
- | Out[1]: | + | |
- | | + | |
- | 0 | + | |
- | 1 202105 | + | |
- | 2 202108 | + | |
- | 3 202111 | + | |
- | In [2]: | ||
- | copart_earnings = pd.DataFrame({ | ||
- | ' | ||
- | ' | ||
- | }) | ||
- | copart_earnings | ||
- | Out[2]: | ||
- | | ||
- | 0 202104 | ||
- | 1 202107 | ||
- | 2 202110 | ||
- | 3 202201 | ||
- | |||
- | In [3]: | ||
- | dict_df = {' | ||
- | dict_df | ||
- | Out[3]: | ||
- | {' | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | ' | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | |||
- | In [4]: | ||
- | expanded_df = pd.concat(dict_df, | ||
- | expanded_df | ||
- | Out[4]: | ||
- | ticker | ||
- | 0 | ||
- | 1 | ||
- | 2 | ||
- | 3 | ||
- | 4 | ||
- | 5 | ||
- | 6 | ||
- | 7 | ||
- | </ |
task_boiler.txt · Last modified: 2024/01/23 22:55 by raju