我有一个用弧度表示Lan / Lon的csv,我想将它们更改为度。我知道可以通过迭代和180 / pi来完成,但是我正在寻求一种更简单的方法。
# read file and store in file variable
file = open("Stop Word.txt", "r")
# create global array
lists = []
# create header
def startingProgram():
print("=" * 70)
print("Masukkan Pesan: (untuk berhenti masukkan string kosong)")
print("=" * 70)
# clean punctuation and conjunction
def message(userInput):
punctuation = "!@#$%^&*()_+<>?:.,;/"
words = userInput.lower().split()
conjunction = file.read().split("\n")
removePunc = [char.strip(punctuation) for char in words if char not in conjunction]
global lists
lists = removePunc
return removePunc
# sort and count duplicate string
def counting(words):
w_unq = sorted(((item, words.count(item)) for item in set(words)), key=lambda x: x[1], reverse=True)
count = 1
for u in w_unq:
print("{}\t{:<10}\t{:<0}".format(count,*u))
count += 1
# create table
def table():
print("Distribusi Frekuensi Kata: ")
print("-"*70)
print("{}\t{:<10}\t{:<0}".format("No","Kata","Frekuensi"))
print("-"*70)
# run program
startingProgram()
pesan = None
while pesan != "":
pesan = input("Pesan: ")
message(pesan)
table()
counting(lists)
我想使用degres导出准确的csv
答案 0 :(得分:0)
将要转换的列分组为列表,并将其用作索引,然后调用transform:
data = pd.read_csv(load , delimiter=';')
cols=[['ARS_GPS.GPSCycle.GPS_GEN_POS_FIX.Latitude','ARS_GPS.GPSCycle.GPS_GEN_POS_FIX.Longitude']]
data[cols]= data[cols].transform(lambda rad: rad*180/math.pi)
data.to_csv("new.csv",sep=";")
编辑: 从@Quang Hoang的示例中学到,您可以编写:
data[cols]= np.rad2deg(data[cols])