Create a single-column from a pandas data frame with n columns
Question:
I have a data frame with 3 columns: A, B and C as below:
A:
1
2
3
B:
10
20
30
C:
100
200
300
I need to save the values only in a csv file in "one" row like this ( no need to save the column name)
1 2 3 10 20 30 100 200 300
I tried to create a new data frame with only one coumn using pandas, and transpose it, then write it to a csv file. But I couln’t figure out how. Could you please help me?
Answers:
I have a data frame with 3 columns: A, B and C as below:
A:
1
2
3
B:
10
20
30
C:
100
200
300
I need to save the values only in a csv file in "one" row like this ( no need to save the column name)
1 2 3 10 20 30 100 200 300
I tried to create a new data frame with only one coumn using pandas, and transpose it, then write it to a csv file. But I couln’t figure out how. Could you please help me?