I have data as shown here:
SampleNumber X A B
0 1 120 2 4
1 2 120 2 4
2 3 120 2 4
3 4 120 2 4
4 5 120 2 4
5 6 120 2 4
6 7 0 2 4
7 8 0 2 4
8 9 0 2 4
9 10 0 2 4
10 11 0 2 4
11 12 0 2 4
12 13 0 2 4
13 14 150 2 4
14 15 150 2 4
15 16 0 2 4
16 17 0 2 4
17 18 135 2 4
18 19 135 2 4
19 20 0 2 4
20 21 0 2 4
I have a column X where most of the values of the same and values sometimes changes I need data when the values in column X changes and it is not 0.
Output: I need samples: 1, 14,18 The way I am doing is
common_t_filtered_df['C'] = common_t_filtered_df['X'].diff()
df_filtered = common_t_filtered_df[common_t_filtered_df['C']!=0]
try:
df_filtered = df_filtered[df_filtered['X'] != 0]
df_filtered = (df_filtered[['A','B','X','SampleNumber']]).values
I keep getting this error:
line:err: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy common_t_filtered_df['C'] = common_t_filtered_df['X'].diff()
Can someone let me know how can I get rid of this error or maybe there is some smart idea of getting the values. Btw 120,150,135 are just examples, it can be anything.