OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Empty dataframes in jupyterlab

  • Thread starter Thread starter naiyaluna
  • Start date Start date
N

naiyaluna

Guest
I am not receiving error messages in my current script- but I am being told that as soon as I start dropping any NaN values, all of my dataframes are empty, so there is nothing to graph. Here is my script below

Code:
#converting time data to integer values
rawTime= pd.to_datetime(data.iloc[3:, 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, 51)]

#pulling indexed data- this didnt work- got different shapes from 50 
#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")

# Adjusting the range to match the length of `names`
num_sensors = len(names)
tiltX_cols = list(range(5, 5 + 4 * num_sensors, 4))
tiltY_cols = list(range(6, 6 + 4 * num_sensors, 4))

# Determine the end row dynamically
end_row = data.shape[0]

# Pulling indexed data
tiltX = data.iloc[3:end_row, tiltX_cols].set_axis(names[:len(tiltX_cols)], axis="columns")
tiltY = data.iloc[3:end_row, tiltY_cols].set_axis(names[:len(tiltY_cols)], axis="columns")

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

# Create a DataFrame for deltaTime- this is the area I start receiving empty dataframes
deltaTime_df = pd.DataFrame(deltaTime, index=data.index[3:end_row], columns=['deltaTime'])

# Ensure all columns are numeric
tiltX = tiltX.apply(pd.to_numeric, errors='coerce')
tiltY = tiltY.apply(pd.to_numeric, errors='coerce')

# Remove NaN values by interpolation
tiltXWithoutNaN = tiltX.interpolate().dropna().join(deltaTime)
tiltYWithoutNaN = tiltY.interpolate().dropna().join(deltaTime)

# Join with deltaTime ensuring proper alignment
tiltXWithoutNaN = tiltXWithoutNaN.join(deltaTime_df, how='inner')
tiltYWithoutNaN = tiltYWithoutNaN.join(deltaTime_df, how='inner')
<p>I am not receiving error messages in my current script- but I am being told that as soon as I start dropping any NaN values, all of my dataframes are empty, so there is nothing to graph. Here is my script below</p>
<pre><code>#converting time data to integer values
rawTime= pd.to_datetime(data.iloc[3:, 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, 51)]

#pulling indexed data- this didnt work- got different shapes from 50
#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")

# Adjusting the range to match the length of `names`
num_sensors = len(names)
tiltX_cols = list(range(5, 5 + 4 * num_sensors, 4))
tiltY_cols = list(range(6, 6 + 4 * num_sensors, 4))

# Determine the end row dynamically
end_row = data.shape[0]

# Pulling indexed data
tiltX = data.iloc[3:end_row, tiltX_cols].set_axis(names[:len(tiltX_cols)], axis="columns")
tiltY = data.iloc[3:end_row, tiltY_cols].set_axis(names[:len(tiltY_cols)], axis="columns")

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

# Create a DataFrame for deltaTime- this is the area I start receiving empty dataframes
deltaTime_df = pd.DataFrame(deltaTime, index=data.index[3:end_row], columns=['deltaTime'])

# Ensure all columns are numeric
tiltX = tiltX.apply(pd.to_numeric, errors='coerce')
tiltY = tiltY.apply(pd.to_numeric, errors='coerce')

# Remove NaN values by interpolation
tiltXWithoutNaN = tiltX.interpolate().dropna().join(deltaTime)
tiltYWithoutNaN = tiltY.interpolate().dropna().join(deltaTime)

# Join with deltaTime ensuring proper alignment
tiltXWithoutNaN = tiltXWithoutNaN.join(deltaTime_df, how='inner')
tiltYWithoutNaN = tiltYWithoutNaN.join(deltaTime_df, how='inner')
</code></pre>
 
Top