extract text from a column of delimiters python

You can find the documentation for the split() function here.

To do this with split():

str(date).split(" ")[0]

This splits on the whitespace and return the first (0 indexed) value in the resulting list. With this change your for loop would look like this:

for date in split_dates:
    df1 = df[df['DateFull'] == date]
    split_file_name ="Samplefile_" + str(date).split(" ")[0] + ".csv"

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top