Skip to content

Commit 27d7239

Browse files
committed
renamed python files
1 parent 5fd660f commit 27d7239

File tree

8 files changed

+33
-0
lines changed

8 files changed

+33
-0
lines changed
File renamed without changes.

dollar_format.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# -*- coding: utf-8 -*-
2+
3+
import pandas as pd
4+
5+
6+
FILE_TO_READ = "./sample_files/dollar_number.csv" #replace with your file name
7+
8+
COMMA = True # add comma after every 3 digits
9+
10+
def conver_to_dollar(FILE_TO_READ,COMMA):
11+
12+
df = pd.read_csv(FILE_TO_READ)
13+
14+
if COMMA == True:
15+
df['amount'] = df['amount'].map('${:,}'.format) # add dollar & comma
16+
else:
17+
df['amount'] = df['amount'].map('${}'.format) # add only dollar next to the number
18+
19+
df.to_csv(FILE_TO_READ, index=False)
20+
21+
22+
def main():
23+
conver_to_dollar(FILE_TO_READ, COMMA)
24+
25+
if __name__ == "__main__":
26+
main()
27+

images/dollar.png

7.69 KB
Loading
File renamed without changes.
File renamed without changes.
File renamed without changes.

sample_files/dollar_number.csv

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
amount
2+
123456
3+
1234
4+
123
5+
2345678
6+
10000000
File renamed without changes.

0 commit comments

Comments
 (0)