I do have a dataframe containing multiple rows where the first row contains parameter estimates and the row below contains the respective t-statistics.
Row 1: Par. Est. 1 | Par. Est. 2 | Par. Est. 3 ...
Row 2: t-Stat 1 | t-Stat 2 | t-Stat 3 ...
Row 3: Par. Est. 1 | Par. Est. 2 | Par. Est. 3 ...
Row 4: t-Stat 1 | t-Stat 2 | t-Stat 3 ...
I want to modify the rows with the t-Stats so that the values are all individually displayed in brackets, i.e. so that it looks like this:
Row 1: Par. Est. 1 | Par. Est. 2 | Par. Est. 3 ...
Row 2: (t-Stat 1) | (t-Stat 2) | (t-Stat 3) ...
Row 3: Par. Est. 1 | Par. Est. 2 | Par. Est. 3 ...
Row 4: (t-Stat 1) | (t-Stat 2) | (t-Stat 3) ...
I literally have no idea how to start or how to do it.
CodePudding user response:
If I understand correctly, you can use
df.iloc[1::2,:] = df.iloc[1::2,:].add(')').radd('(')