'How to concat files creating codes for each of than?
the first thing I need to know is if exists a way to create two columns when I read a file and fill the column with the filename code(a filename ex: abcd275-2016-10-01, efg275-2016-10-01), the files always have 3 or 4 letters, a code and a day, I only want the letters and the day.
this is an example of the Dataframe i would like to built:
Dados 1 | Dados 2 | Dados 3 | Dados 4 | Code | Day |
---|---|---|---|---|---|
0 | 4.00 | 4 | -3.95 | abcd | 2016-10-01 |
1 | 8.00 | 4 | -3.95 | abcd | 2016-10-02 |
2 | 2.00 | 4 | -3.95 | abcd | 2016-10-02 |
6 | 3.97 | 6 | -2.79 | efg | 2016-10-01 |
7 | 3.80 | 5 | -2.79 | efg | 2016-10-01 |
8 | 5.97 | 7 | -2.79 | efg | 2016-10-02 |
I tried this code but the first the DataFrame dados in the final of the loop don't got anything and I need it to get all the files DataFrames that tmp_df read
dados = pd.DataFrame(columns=head_files)
for i in diretorio_vtec:
tmp_df = pd.read_table(i,
names=head_files)
dados = pd.merge(dados, tmp_df)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|