回答編集履歴
3
修正
test
CHANGED
@@ -8,12 +8,14 @@
|
|
8
8
|
|
9
9
|
```Python
|
10
10
|
|
11
|
+
path = file
|
12
|
+
|
11
13
|
with codecs.open(file, "r", "cp932", "ignore") as file:
|
12
14
|
|
13
15
|
df = pd.read_table(file, delimiter=",", skipinitialspace = True)
|
14
16
|
|
15
17
|
after = df.drop_duplicates()
|
16
18
|
|
17
|
-
after.to_csv(
|
19
|
+
after.to_csv(path, encoding="cp932")
|
18
20
|
|
19
21
|
```
|
2
修正
test
CHANGED
@@ -1,3 +1,19 @@
|
|
1
1
|
`df.to_csv(after, encoding="cp932")`→`after.to_csv('出力ファイルパス(hoge.csvなど)', encoding="cp932")`であるべきです。
|
2
2
|
|
3
3
|
[pandas.DataFrame.to_csv](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.to_csv.html)で引数を確認ください。
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
入力ファイルに上書き保存するには以下のように修正ください。
|
8
|
+
|
9
|
+
```Python
|
10
|
+
|
11
|
+
with codecs.open(file, "r", "cp932", "ignore") as file:
|
12
|
+
|
13
|
+
df = pd.read_table(file, delimiter=",", skipinitialspace = True)
|
14
|
+
|
15
|
+
after = df.drop_duplicates()
|
16
|
+
|
17
|
+
after.to_csv(file, encoding="cp932")
|
18
|
+
|
19
|
+
```
|
1
修正
test
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
`df.to_csv(after, encoding="cp932")`→`after.to_csv(
|
1
|
+
`df.to_csv(after, encoding="cp932")`→`after.to_csv('出力ファイルパス(hoge.csvなど)', encoding="cp932")`であるべきです。
|
2
2
|
|
3
3
|
[pandas.DataFrame.to_csv](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.to_csv.html)で引数を確認ください。
|