Python Forum
doing data treatment on a file import-parsing a variable
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
doing data treatment on a file import-parsing a variable
#15
Sure. You could use apply() which gives you more freedom in what you can do.
dictionary["Number"] = dictionary["ID"].apply(lambda x: x.split("-")[1])
I think it is better to stay with the current solution and either ignore the extra column or drop it.
dictionary.drop(axis=1, labels=["SAMPLE ID"])
or
new_dictionary = dictionary[["names", "of", "columns", "i", "want", "to", "keep"]]
Reply


Messages In This Thread
data - by EmBeck87 - Apr-17-2023, 06:54 PM
RE: doing data treatment on a file import-parsing a variable - by deanhystad - Mar-30-2023, 08:25 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Help with writing monitored data to mysql upon change of one particular variable donottrackmymetadata 3 428 Apr-18-2024, 09:55 PM
Last Post: deanhystad
  Plot a pandas data fram via pyqtgraph with an modul import and qt designer widget Nietzsche 0 920 May-29-2023, 02:42 PM
Last Post: Nietzsche
  Python 3.11 data import question love0715 2 878 Mar-05-2023, 06:50 PM
Last Post: snippsat
  Import XML file directly into Excel spreadsheet demdej 0 915 Jan-24-2023, 02:48 PM
Last Post: demdej
  Need help on how to include single quotes on data of variable string hani_hms 5 2,255 Jan-10-2023, 11:26 AM
Last Post: codinglearner
  USE string data as a variable NAME rokorps 1 1,033 Sep-30-2022, 01:08 PM
Last Post: deanhystad
  Can't import csv data JonWayn 4 1,497 Sep-18-2022, 02:07 AM
Last Post: JonWayn
Question How can I import a variable from another script without executing it ThomasFab 12 8,161 May-06-2022, 03:21 PM
Last Post: bowlofred
  json api data parsing elvis 0 972 Apr-21-2022, 11:59 PM
Last Post: elvis
  Modify values in XML file by data from text file (without parsing) Paqqno 2 1,816 Apr-13-2022, 06:02 AM
Last Post: Paqqno

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020