Skip to main content
The 2024 Developer Survey results are live! See the results

All Questions

Tagged with
0 votes
0 answers
44 views

Why one of the label bars have their name omited in the graph displayed on Jupyter Notebook?

I have the multiindex dataframe (example below but not complete) named "pivot_dftable" and the code below displaying the analysis I need for it. I would like to understand why in the graph ...
Paulo Cortez's user avatar
2 votes
2 answers
73 views

Cumulative sum in Pandas DataFrame based on multiple column value matches between two dataframes

I have two Dataframes. Dataframe1(df1): has 4 columns as shown below. X Y A( in days) B(sum) a aa 7 a bb 9 b aa 36 c dd 29 Column X and Column Y are strings and Column A in days and another ...
One_more_time's user avatar
0 votes
0 answers
26 views

Pivot multiindex pandas dataframe [duplicate]

I am trying to reshape a multiindex pandas dataframe. A sample of the original dataframe is below. import pandas as pd import numpy as np idx = pd.MultiIndex.from_product([ ['2023-06-30', '2023-...
gernworm's user avatar
  • 340
0 votes
2 answers
50 views

Why does pandas .reindex() not keep data with equivalent sized index? [duplicate]

Lets say we have this dummy data : dates=pd.date_range("2020-02-01","2021-02-01",freq="MS") features=["foo","bar"] cols=pd.MultiIndex.from_product([...
Nathan Keloglanian's user avatar
4 votes
4 answers
85 views

How to replace an individual level in a multi-level column index in pandas

Consider the following multi-level column index dataframe: import numpy as np import pandas as pd arrays = [ ["A", "A", "B", "B"], ["one", &...
Andi's user avatar
  • 4,011
2 votes
1 answer
64 views

Group Pandas DataFrame on criteria from another DataFrame to multi-index

I have the following two DataFrames: df 100 101 102 103 104 105 106 107 108 109 0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0 2 ...
NicoH's user avatar
  • 1,343
1 vote
2 answers
89 views

How to melt/stack multiindex headers with pandas?

I have an Excel file containing credit spread calculations for different credit ratings. The structure includes merged cells which create multi-level column headers. Here is an example of the ...
Forecaster's user avatar
0 votes
0 answers
47 views

Pandas MultiIndex Duplication Issue When Aligning Factor Data for Alphalens

Question: I'm encountering an issue with duplicated index levels in a Pandas MultiIndex DataFrame when calculating factor returns using Alphalens. My factor_data contains both factor and ...
Aboriginal's user avatar
0 votes
1 answer
59 views

Pandas Multiidex concat

list of dataframes (ex. dfs = [df1, df2, ...]) all dataframe columns is multiindex (ex. [("something", "id",), ("something", "age"), ...]) i want to set "...
bhnvx's user avatar
  • 25
0 votes
1 answer
32 views

Categorical column to multiple count columns [duplicate]

Suppose we have a DataFrame: data = {'person_id': ['person_a', 'person_a', 'person_b','person_b', 'person_c','person_c'], 'categorical_data': ['new', 'new', 'ok', 'bad', 'new', 'bad']} df = pd....
MrChomp's user avatar
1 vote
1 answer
24 views

Select multi-index when one subindex obeys condition

If I build a dataframe like this arrays = [ np.array(["bar", "bar", "baz", "baz", "foo", "foo", "qux", "qux"]), ...
David's user avatar
  • 1,257
1 vote
1 answer
37 views

Is a pandas MultiIndex a counterpart to a SQL composite index?

I posted this on reddit some days ago, but haven't received any response. Everything I've read online about the pandas MultiIndex makes it seem like a counterpart to a SQL composite index. Is this ...
user2153235's user avatar
  • 1,052
2 votes
2 answers
51 views

Discontinuous selections with pandas MultiIndex

I have the following DataFrame with MultiIndex columns (the same applies to MultiIndex rows): import pandas as pd df = pd.DataFrame(columns=pd.MultiIndex.from_product([['A','B'],[1,2,3,4]]), ...
germ's user avatar
  • 1,627
0 votes
1 answer
45 views

How to build a MultiIndex DataFrame from a dict of data and a dict of index levels

I'm struggling with the creation of this DataFrame A B x y a 1 2 1 2 6 3 c 2 7 2 from these two dictionaries which seem sufficient: data = {'A': [2,6,7], 'B': [1,3,2]} ...
mins's user avatar
  • 7,235
0 votes
0 answers
27 views

Pandas MultiIndex Rolling Group by

Pandas has some very strange group by behavior with Multi_indexing. I don't understand why one of these sites is not being calculated but when called alone works perfectly fine. Consider the following ...
ZdWhite's user avatar
  • 501

15 30 50 per page
1
2 3 4 5
170