hierarchical-data

Detect parent rows of each row and add their values to a new column

Detect immediate parent rows of each row and add their values to a new column Question: I have a dataframe that contains multiple hierarchy columns and a value attach to them, something like this: location hierarhcy industry hierarchy value 0 US All V1 1 US-California All V2 2 US-California All-HT V3 3 US-California-LA All V4 …

Total answers: 1

Efficient Way to Build Large Scale Hierarchical Data Tree Path

Efficient Way to Build Large Scale Hierarchical Data Tree Path Question: I have a large dataset (think: big data) of network elements that form a tree-like network. A toy dataset looks like this: | id | type | parent_id | |—–:|:——-|:————| | 1 | D | <NA> | | 2 | C | 1 | …

Total answers: 1

Python: Create DataFrame with hierarchical columns and add columns

Python: Create DataFrame with hierarchical columns and add columns Question: I have a DataFrame with a multiindex as follows: df: open close date Symbol 2022-01-01 SPY 100 102 TSLA 232 245 2022-01-02 SPY 103 100 TSLA 222 220 AAPL 143 147 I want to convert this into a DataFrame with hierarchical columns and add another …

Total answers: 1

Resampling Within a Pandas MultiIndex

Resampling Within a Pandas MultiIndex Question: I have some hierarchical data which bottoms out into time series data which looks something like this: df = pandas.DataFrame( {‘value_a’: values_a, ‘value_b’: values_b}, index=[states, cities, dates]) df.index.names = [‘State’, ‘City’, ‘Date’] df value_a value_b State City Date Georgia Atlanta 2012-01-01 0 10 2012-01-02 1 11 2012-01-03 2 12 …

Total answers: 8