• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: the else block in the following code isn’t working and only the if statement is being executed to calculate the volume. What is going wrong?

Resolved: the else block in the following code isn’t working and only the if statement is being executed to calculate the volume. What is going wrong?

0
By Isaac Tonny on 17/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

def volume(df):

I am working to calculate volume of a diamond dataset where dimensions x,y,z and depth are given and I have to calculate volume = xyz when depth >60 else volume is to be set to 8 but the code I have written is not assigning volume =8 when depth <60 and simply calculates volume = xyz , perhaps the code isn’t taking the else condtion initially is what i thought so I used a counter a which incremented by one when else block was executed and I printed its value successfully (my debug attempt) . Can you guys help me out in this ? Thanks in advance


Answer:

Instead of looping, try this code:

If you have better answer, please add a comment about this, thank you!

debugging if-statement pandas python
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: How can I write CSS selector(s) that apply to table rows for all td elements on that row after a td with a certain class?

01/04/2023

Resolved: How do I use SetWindowText with Unicode in Win32 using PowerShell?

01/04/2023

Resolved: Shopware 400 Status Error “This value is too long. It should have 255 character or less.” When I Try Updating Database Table

01/04/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.