データ1
A B C D E <--- columns
a b c d e
a b c d e
a b c d e
result what i want
A B C D E <--- columns
A B C D E <--- columns
A B C D E <--- columns
a b c d e
a b c d e
a b c d e
私はこれを探しましたが、最終的に失敗しました:)
良い結果を得るにはどうすればよいですか?私はあなたの助けを求めます。ありがとうございました
どうもありがとうございました
Excel に変換すると、新しい空の列が作成されました。
test
a b c d e f g h i j k l m n o p q r s t u v w x y
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
dir_path = os.path.dirname(os.path.realpath(__file__))
df = pd.read_excel(dir_path + '/import/sample.xlsx', header=0)
headers = [list(df.columns), list(df.columns), list(df.columns)]
df.columns = pd.MultiIndex.from_arrays(headers)
writer = pd.ExcelWriter(dir_path + '/export/sample.xlsx', options={'strings_to_urls': False}, )
df.to_excel(writer, sheet_name='result')
writer.save()
result
a b c d e f g h i j k l m n o p q r s t u v w x y
a b c d e f g h i j k l m n o p q r s t u v w x y
a b c d e f g h i j k l m n o p q r s t u v w x y
<<<<---- empty row ---->>>> 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
3 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
私はそれを取り除こうとしましたが失敗しました。
df = df[df['a'] != ""]