I'm a newbie in Pandas and regular expressions.

I want to obtain from a file, the dates in a determined format, order by time and show the index position in a new column.

The requirement is from the main code read the file and call a function to solve the problem mentioned.

So, I created a function to obtain the results and it is found right, but apparently, some problems appear (warning in the code), and I'm not ending to understand why.

Maybe, the warning appears when the data frame sends the data to the function.

Some recommendation ?
Does anybody help me to discover what I doing wrong?

**I did the following code:**

```html
def date_sort():
    import re
    import pandas as pd
    import sys

    df = pd.DataFrame(date_reader, columns=['year'])
    #search the digits
    df1=df['year'].str.extract(r'(\d?\d\d\d)')
    df2 = pd.DataFrame(df1, columns=['year'])
    #count 4 digits
    df2['year'].str.len()
    #orderby
    df3=df2.sort_values(["year"])
    #Add new column
    tabla=df3.reset_index()

    return tabla #return the results to show in main code

#main code that call the function

import pandas as pd
import re

with open('text_with_lot_of_text_and_dates.txt') as file:
    for lines in file:
        tot6 = file.read()
        date_reader = re.findall(r'(?:\d{1,2} )?(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Nov|Dec)[a-z]* (?:\d{1,2}, )?\d{4}',tot6)    

result = date_sorter()

print(result.T.head(1).T)
```

**The main code shows:**

```
    ['24 Jan 2001', '10 Sep 2004', '26 May 1982', '28 June 2002', '06 May 1972', '30 Nov 2007', '28 June 1994', '14 Jan 1981', '11 February 1985', '10 Feb 1983', '05 Feb 1992', '14 Feb 1995', '30 May 2016', '22 Jan 1996', '11 Nov 2004', '30 May 2001', '02 Feb 1978', '09 Sep 1989', '12 March 1980', '22 June 1990', '28 Sep 2015', '13 Jan 1972', '06 Mar 1974', '26 May 1974' ... ]

    0    2001
    1    2004
    2    1982
    3    2002
    4    1972
    5    2007   

```

**The function returns:**

a) The function doing all activities to create a new column with the position of the index of the each data year value, and retun to main function:

```
     index  year
0        4  1972
1       21  1972
2       47  1972
3       72  1972
4      162  1973
5      154  1973

```

**The main function shows:**
the main function only shows the first column with the new\_colum\_index and the index:

```
    index
0       4
1      21
2      47
3      72
4     162
5     154

```

**The error that appear:**

```
FutureWarning: currently extract(expand=None) means expand=False (return Index/Series/DataFrame) but in a future version of pandas this will be changed to expand=True (return DataFrame)

```

Thanks in advance !!