'Numpy where function in python
I have a data frame like this:
pd.DataFrame({'Material': ['Steel (16MnCr5)', 'X', 'X', 'X', 'Carbon black', 'Sulfur', 'Copper'], 'Weight': [4, 8, 0, 8, 6, 9, 3]})
It gives:
i want to shift up by one cell all the weight that do not correspond to 'X' in Material column. the outcome will then lool like:
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|