key error KeyError: ('accelerometerx', 'lx','mx','gx') i want to add the data of 4 hardware but when i try the error
key error KeyError: ('accelerometerx', 'lx','mx','gx') i want to add the data of 4 hardware but when i try the error
请帮助我想要陀螺仪(gx)磁力计(mx)的加速度计数据但是每当我添加这个
KeyError: ('accelerometerx', 'lx', 'mx','gx') 但是每当我输入 accelerometerx 代码 运行 以及
df['Activity'].value_counts().plot(kind='bar', title='Training examples by activity type');
def plot_activity(Activity, df):
data = df[df['Activity'] == Activity][['gx', 'gy', 'gz','mx','my','mz','lx','ly','lz','accelerometerx','accelerometery','accelerometerz']][:200]
axis = data.plot(subplots=True, figsize=(8, 6),
title=Activity)
for ax in axis:
ax.legend(loc='lower left', bbox_to_anchor=(1.0, 0.5))
df=df.astype(float)
plot_activity(11111, df)
N_TIME_STEPS = 200
N_FEATURES = 3
step = 20
segments = []
labels = []
for i in range(0, len(df) - N_TIME_STEPS, step):
xs = df['accelerometerx', 'lx', 'mx','gx'].values[i: i + N_TIME_STEPS]
ys = df['accelerometery'].values[i: i + N_TIME_STEPS]
zs = df['accelerometerz'].values[i: i + N_TIME_STEPS]
label = stats.mode(df['Activity'][i: i + N_TIME_STEPS])[0][0]
segments.append([xs, ys, zs])
labels.append(label)
np.array(segments).shape
reshaped_segments = np.asarray(segments, dtype= np.float32).reshape(-1, N_TIME_STEPS, N_FEATURES)
labels = np.asarray(pd.get_dummies(labels), dtype = np.float32)
reshaped_segments.shape
您不能像这样 select 多列。您必须为要 select.
的列创建一个列表
将 for
循环中的第一行更改为:
xs = df[['accelerometerx', 'lx', 'mx','gx']].values[i: i + N_TIME_STEPS]
请帮助我想要陀螺仪(gx)磁力计(mx)的加速度计数据但是每当我添加这个 KeyError: ('accelerometerx', 'lx', 'mx','gx') 但是每当我输入 accelerometerx 代码 运行 以及
df['Activity'].value_counts().plot(kind='bar', title='Training examples by activity type');
def plot_activity(Activity, df):
data = df[df['Activity'] == Activity][['gx', 'gy', 'gz','mx','my','mz','lx','ly','lz','accelerometerx','accelerometery','accelerometerz']][:200]
axis = data.plot(subplots=True, figsize=(8, 6),
title=Activity)
for ax in axis:
ax.legend(loc='lower left', bbox_to_anchor=(1.0, 0.5))
df=df.astype(float)
plot_activity(11111, df)
N_TIME_STEPS = 200
N_FEATURES = 3
step = 20
segments = []
labels = []
for i in range(0, len(df) - N_TIME_STEPS, step):
xs = df['accelerometerx', 'lx', 'mx','gx'].values[i: i + N_TIME_STEPS]
ys = df['accelerometery'].values[i: i + N_TIME_STEPS]
zs = df['accelerometerz'].values[i: i + N_TIME_STEPS]
label = stats.mode(df['Activity'][i: i + N_TIME_STEPS])[0][0]
segments.append([xs, ys, zs])
labels.append(label)
np.array(segments).shape
reshaped_segments = np.asarray(segments, dtype= np.float32).reshape(-1, N_TIME_STEPS, N_FEATURES)
labels = np.asarray(pd.get_dummies(labels), dtype = np.float32)
reshaped_segments.shape
您不能像这样 select 多列。您必须为要 select.
的列创建一个列表将 for
循环中的第一行更改为:
xs = df[['accelerometerx', 'lx', 'mx','gx']].values[i: i + N_TIME_STEPS]