0

when I read csv file to dataframe I have two columns (below pic)

for dose_name in dose_list: with open(dose_name,'r+',encoding="utf-8") as f:

    df = pd.read_csv(f)
    
    df_dose = df['dose']
    df_dose_num = df['dose_number']

df looks like this:

PIC HERE

I want to drop rows that have numbers and text that are unnecessary. For example, remove (eg. 1, 0, slow, 06 Jun, 95,..) and leave numbers with units (eg. 100 mg/kg, 10 mg/kg, ..) and output result as csv file.

Can anyone please help? p.s I also have numbers (decimals eg. 10.1, 14.1) and would ideally want to remove these as well.

Thank you in advance :)

JJ_K
  • 23
  • 5
  • Hi there, can you write the code in the question instead of a picture. Also, are the values of rows with only numbers ints? Like the 10 and 95 you put in the example. Where are the decimal numbers? – DPM Oct 29 '20 at 23:40
  • 1
    Looks like you are looking to create a regex, but do not know where to get started. Please check [Reference - What does this regex mean](https://stackoverflow.com/questions/22937618) resource, it has plenty of hints. Also, refer to [Learning Regular Expressions](https://stackoverflow.com/questions/4736) post for some basic regex info. Once you get some expression ready and still have issues with the solution, please edit the question with the latest details and we'll be glad to help you fix the problem. – Wiktor Stribiżew Oct 29 '20 at 23:45
  • @DPM hi I have included the code but it's just importing csv file that contains information that's in the pic. In other document, it also has decimal numbers. – JJ_K Oct 30 '20 at 00:22

0 Answers0