0

I have this code, in the XML page the DateTime is 01052022000000000, but when it comes to python it appears like 1052022000000000 (the left zero was deleted).

I try to use ( apply('{:0>17}'.format) ) but nothing happen.

any help?

import pandas as pd
import pandas as pd

url = (
    "http://90.161.233.78:65518/services/user/records.xml?"
    "begin=01052022?end=01052022?"
    "var=EDSLINEEMBEDDED.Module2.AE1?var=EDSLINEEMBEDDED.Module2.VI1?period=900")

df = pd.read_xml(url, xpath="//record/* | //dateTime") 
df["dateTime"] = df["dateTime"].ffill()
print(df["dateTime"])
df['dateTime']=df['dateTime'].apply('{:0>17}'.format)
print(df["dateTime"])
mzjn
  • 48,958
  • 13
  • 128
  • 248

1 Answers1

0

Have you tried:

df['dateTime'] = df['dateTime'].str.zfill(18)

Poder Psittacus
  • 94
  • 1
  • 10