Issues with dataframe shapes in creating a seismogram using Python

I have been trying to create a seismogram for quite a while but keep running into bugs. I was successful in creating a seismogram for a set of small data, but am now working with a larger set and seem to be running into issues with keeping time consistent with data (dropping NaNs while moving through data) and ignoring shapes of dataframes… the goal is to have this code be usable for different sizes of dataframes.

This is the code script for what I successfully generated a seismogram with: (excluding my csv name)
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
#converting time data to integer values
rawTime= pd.to_datetime(data.iloc[4:4601, 0], format = ‘%m/%d/%Y %H:%M’)
deltaTime = (rawTime-rawTime.iloc[0]).astype(np.int64) /(10e8*60)

#name generation for instruments
names = ["GeoFlex" + str(i) for i in range(1,31,1)]

#pulling indexed data
tiltX = data.iloc[4:4601, range(5, 122, 4)].set_axis([names], axis="columns")
tiltY = data.iloc[4:4601, range(6, 123, 4)].set_axis([names], axis="columns")
voltage = data.iloc[4:4601, range(7, 124, 4)].set_axis([names], axis="columns")
tempC = data.iloc[4:4601, range(8, 125, 4)].set_axis([names], axis="columns")

#removing NaN values without changing index
tiltXWithoutNaN = tiltX.join(deltaTime).dropna().astype(float)
tiltYWithoutNaN = tiltY.join(deltaTime).dropna().astype(float)
tempCWithoutNaN = tempC.join(deltaTime).dropna().astype(float)
voltageWithoutNaN = voltage.join(deltaTime).dropna().astype(float)

#calculations for displacement (equations provided by GeoFlex documentation)
displacementMagnitudeX =              (tiltXWithoutNaN.iloc[:,0:30]*0.6).diff(axis=0).dropna().join(deltaTime).rename(columns={"Column1":"Time"})
displacementMagnitudeY = (tiltYWithoutNaN.iloc[:,0:30]*0.6).diff(axis=0).dropna().join(deltaTime).rename(columns={"Column1":"Time"})

#some good ol pythagorean
displacementTotal = pd.DataFrame(np.sqrt((
    abs(displacementMagnitudeX.iloc[:,0:30])**2)+(
    abs(displacementMagnitudeY.iloc[:,0:30])**2))).join(deltaTime).rename(columns={"Column1":"Time"})

#plotting
plt.rcParams.update({'font.size': 7})
fig = plt.figure(layout='constrained')
spec = fig.add_gridspec(2,2)

#plot1
ax3 = fig.add_subplot(spec[0,:])
ax3.plot(displacementTotal.iloc[:,30],displacementTotal.iloc[:,0:10], ls=':', linewidth='0.7')
ax3.axis([0,9000,0,0.3])
ax3.set_xlabel("Time[minutes]")
ax3.set_ylabel("Magnitude of Displacement of Sensor [mm]")
ax3.set_title("Fig 1: Seismogram")

Now here is the code I have been attempting to use for a newer, larger data set:

# importing packages
import numpy as np
import pandas as pd
import matplotlib as plt


# name generation for instruments
names = ["GeoFlex" + str(i) for i in range(1,51,1)]

# dropping NaN and loading displacemts 
data2 = data.dropna(inplace=True)
tiltX = data2.iloc[:, 5]
tiltY = data2.iloc[:, 6]

# time to datetime
time = pd.to_datetime(data.iloc[4:, 0], format='%m/%d/%Y %H:%M')
data2.set_index(time, inplace=True)

#Editing time to fit format
minutes_since_start = (displacementTotal.index - displacementTotal.index[0]).total_seconds() / 60

# Convert tiltX, tiltY, etc., to DataFrame, join with time, then drop NaN values
tiltX_df = tiltX.to_frame(name='tiltX')
tiltY_df = tiltY.to_frame(name='tiltY')

# Join each with time. Here we assume 'time' is the DataFrame with 'Time' as its index.
tiltXWithoutNaN = tiltX_df.join(time, how='inner').dropna()
tiltYWithoutNaN = tiltY_df.join(time, how='inner').dropna()

# Now, you can apply 'astype(float)' to just the sensor data columns, if necessary:
tiltXWithoutNaN['tiltX'] = tiltXWithoutNaN['tiltX'].astype(float)
tiltYWithoutNaN['tiltY'] = tiltYWithoutNaN['tiltY'].astype(float)

#calculations for displacement (equations provided by GeoFlex documentation)
displacementMagnitudeX = (tiltXWithoutNaN.iloc[:,0:50]*0.6).diff(axis=0).dropna().join(time).rename(columns={"Column1":"Time"})
displacementMagnitudeY = (tiltYWithoutNaN.iloc[:,0:50]*0.6).diff(axis=0).dropna().join(time).rename(columns={"Column1":"Time"})

#pythagorean
displacementTotal = pd.DataFrame(np.sqrt((
        abs(displacementMagnitudeX.iloc[:,0:50])**2)+(
        abs(displacementMagnitudeY.iloc[:,0:50])**2))).join(time).rename(columns={"Column1":"Time"})

plt.figure(figsize=(10, 5))
plt.plot(minutes_since_start, y, label='Sensor Displacement')
plt.xlabel("Time [minutes]")
plt.ylabel("Magnitude of Displacement of Sensor [mm]")
plt.title("Fig 1: Seismogram")
plt.legend()
plt.show()

Any ideas why my plots are either empty or just filled with errors?

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật