new column is the sum of two consecutive rows - pandas

please your gentile help, anyone can help me with pandas-python
I need a new column, this new column is the sum of two consecutive rows, (figure)
enter image description here

You could look at the table.assign(<new column> = <formula>) function to build out your dataframe.

Related

How to show number of columns based on slicer in power BI?

I have one scenerio which i need answer for.
Suppose i have a table with 10 columns.
Is it possible to show columns based on slicer.
Like if i select 3 from slicer then it should show only first 3 columns.
Similarly if i select 5 in slicer then the visual should show only first 5 columns.
I really need a solution for this problem. Let me know if any more details required. Thank you
Found an article regarding this please go through with this.
https://community.powerbi.com/t5/Community-Blog/Dynamic-Hideable-Columns-in-Power-BI-Table-Visual/ba-p/662808
If you want to hide/show column based on their name from slicer then please apply below steps:
Go to Transform Data & Select that column which you always want in your table.
Do Unpivoted other columns.
Use a matrix:
Drag static column in ROW of matrix.
Drag Attribute column in Columns of matrix.
Drag Values column in Values of matrix.
4.Drag a slicer & put attribute in Slicers.
Now you can choose column name from slicer which you want to add in your matrix.

Excel - Loop through rows and reverse order

I was looking for a code that loop through all rows (I got too many), and change order for every three rows. I have a form of rows like this...
see image
Need to loop through all rows in column B and reverse order for every three rows and get this (for better analysis). Thank you
see image
If I understand your question correctly, type this formula into a cell in column B and drag down as far as necessary:
= INDEX(A:A,ROW()+2*(1-MOD(ROW()-1,3)))
VBA is not needed. This formula copies the values from column A to column B, but reverses the order of the entries every three rows as shown in your example image from your question.
See below.

Adding a row between cell with the same value using VBA code

Im new in VBA and want to know how can i format my table in such a way that each name in Column one do only have 1 row in between.
Some of them do have more than 1 row in between and some of them doesn't have. I just need to format then in such a way where every name on column A has 1 blank row in between. Any help would be appreciated!
Please note that i have thousands of data so manual will not work.
also i tried doing the filtering and convert them into single block. the problem with single block is that my column c do have more than 1 information which is connected to column a, .
here is an example.enter image description here

add numbers down a column in OpenRefine

I'd like to automatically number a column. Similar to Excel, where I can type "1" in one cell and the cells below it automatically get numbered 2, 3, 4, 5, etc. I don't know why I'm having so much trouble figuring out this function on Openrefine but any help would be greatly appreciated.
Thanks,
Gail
You can add a new column ("Add new column based on this column") with this Grel formula inside :
row.index + 1
The answer by Ettore Rizza already provides a solution for the common case. As the question author stated in a comment it does not work for his use case. He wants to add consecutive numbers to unfiltered rows.
For this you can use records. The basic idea is to create records from the filtered data and use the record index as counter.
Steps:
With filters active add a new column with the expression value.
Move the new column to the beginning to use it as records.
With filters still active add a new column (or transform the first one) with the expression row.record.index + 1.
Original
Filtered
Records
Index
A
A
A
1
1
2
B
B
B
2
C
C
C
3

Concatenating alternate columns

I have 10,000 rows and unlimited data in columns. Two parameters in adjacent columns and are repeating after 13 unwanted columns.
I want to concatenate these adjacent columns of a row separated by space
eg:
concatenate(B2,C2,"",P2,Q2,"",AC,AD,"",....)
But I dont know upto which column the data is present.
Can you suggest me a macro which concatenates data upto blank column in one cell of a row and same is continued for first 10,000 rows.
Thanks a lot for help !
First off, are all the rows terminating at the same column? i.e. does every row have data in column AD but not AE?
If the answer to the above is 'yes', then you'll probably want to take a look at:
Range.End()
which is used like:
YourSheet.Range(YourRange).End(xlToRight).Column
(see here for more info)
This will return either
the last column with data (when the starting cell contains data)
or
the first column with data (when the starting cell is empty).
not the last column without data!
Based on your example in the question, your ranges probably start in Column B, P, AC, etc.
If the answer to the above is 'no', then you can use similar functionality, but you'll have to loop through each row...