A bit new to this, my data frame returns empty in the variable explorer, whenever I try to change the column name to something, the column change happens, but the data disappears. I will put the code below, anyone willing to help out please do.
import pandas as pd
h = open("Test_Data.txt")
df = pd.DataFrame(h)
df1 = pd.DataFrame(h, columns =['Remove, Yaw, Pitch, Roll'])
Okay so here is my data when I first read it without editing,
Here is the link
And here is when I change the column name to something , 2nd link
EDIT: I fixed the problem by converting the DataFrame to numpy (Array of objects), and then changing the name of the column, here's the line I used.
arr = df.to_numpy()
CodePudding user response:
I fixed the problem by converting the DataFrame to numpy, and then changing the name of the column, here's the line I used.
arr = df.to_numpy()
CodePudding user response:
Don't open the text file first, just enter the path in the read_csv method of Pandas. This could work, depending on your separator.
import pandas as pd
df = pd.read_csv('Test_Data.txt', sep=" ", columns=['Remove, Yaw, Pitch, Roll'])
