Bird
0
0

How would you reshape it to represent 4 weeks of data with 6 days each, assuming 1 reading per hour per day?

hard📝 Application Q8 of 15
NumPy - Array Manipulation
You have a 1D NumPy array of 24 elements representing hourly temperature readings for one day. How would you reshape it to represent 4 weeks of data with 6 days each, assuming 1 reading per hour per day?
Aarr.reshape(6, 4, 24)
Barr.reshape(4, 6, 24)
Carr.reshape(4, 6, 1)
Darr.reshape(24, 4, 6)
Step-by-Step Solution
Solution:
  1. Step 1: Understand data structure

    24 elements represent 24 hours in a day.
  2. Step 2: Calculate total elements for 4 weeks and 6 days

    4 weeks * 6 days * 24 hours = 576 elements needed, but original array has only 24 elements.
  3. Step 3: Check options for logical reshape

    Only arr.reshape(4, 6, 1) reshapes to 24 elements total (4*6*1=24), matching original array size.
  4. Final Answer:

    arr.reshape(4, 6, 1) -> Option C
  5. Quick Check:

    Reshape matches total elements [OK]
Quick Trick: Match reshape dims to total elements [OK]
Common Mistakes:
  • Ignoring total elements needed
  • Mixing up dimension order

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NumPy Quizzes