I'm trying to remove the sub string _x that is located in the end of part of my df column names.
Sample df code:
import pandas as pd
d = {'W_x': ['abcde','abcde','abcde']}
df = pd.DataFrame(data=d)
df['First_x']=[0,0,0]
df['Last_x']=[1,2,3]
df['Slice']=['abFC=0.01#%sdadf','12fdak*4%FC=-0.035faf,dd43','FC=0.5fasff']
output:
W_x First_x Last_x Slice
0 abcde 0 1 abFC=0.01
1 abcde 0 2 12fdak*4%FC=-0.035faf,dd43
2 abcde 0 3 FC=0.5fasff
Desired output:
W First Last Slice
0 abcde 0 1 abFC=0.01
1 abcde 0 2 12fdak*4%FC=-0.035faf,dd43
2 abcde 0 3 FC=0.5fasff

所有评论(0)