0

im very new and just trying to learn to clean my data in python using pandas.

i also am trying to learn how to delete other parts of a cell but not all of it, for example -

USPS_MEDIA_CINCINNATI(9102001206932018146748) -- i'd like to just have it read USPS.

any help would be great! thank you!

  • `a="USPS_MEDIA_CINCINNATI(9102001206932018146748)" a[:4]` or split by '_' – Mohsen Oct 02 '20 at 19:52
  • if you want to only keep the first 4 characters of a string in a dataframe then do `df['some_col'] = df['some_col'].str[:4]` – It_is_Chris Oct 02 '20 at 19:53
  • Each question should be focused on one topic. This was duped, based on the main question shown in the header. – Trenton McKinney Oct 02 '20 at 19:58
  • When asking questions, always provide a [mre] **with code, data, errors, current output, and expected output, as text**. If relevant, plot images are okay. Please see [How to ask a good question](https://stackoverflow.com/help/how-to-ask). And you're expected to [try to solve the problem first](https://meta.stackoverflow.com/questions/261592) – Trenton McKinney Oct 02 '20 at 19:58
  • @ mohsen and chris, thanks for your help! – Michael Choi Oct 02 '20 at 20:01

0 Answers0