Home > Back-end >  pd.concat ends up with ValueError: no types given
pd.concat ends up with ValueError: no types given

Time:08-19

I'm trying to merge two dfs (basically th same df at different time) using pd.concat.

here is my code:

Aujourdhui = datetime.datetime.now()
Aujourdhui = (Aujourdhui.strftime("%X"))

PerfsL1 = pd.read_html('https://fbref.com/fr/comps/13/stats/Statistiques-Ligue-1#all_stats_standard', header=1)[0]
PerfsL1.columns = ['Équipe', 'Used_players', 'age', 'Possesion', "nb_matchs", "Starts", "Min",
                      '90s','Buts','Assists', 'No_penaltis', 'Penaltis', 'Penaltis_tentes',
                      'Cartons_jaunes', 'Cartons_rouges', 'Buts/90mn','Assists/90mn', 'B A /90mn',
                      'NoPenaltis/90mn', 'B A P/90mn','Exp_buts','Exp_NoPenaltis', 'Exp_Assists', 'Exp_NP A',
                      'Exp_buts/90mn', 'Exp_Assists/90mn','Exp_B A/90mn','Exp_NoPenaltis/90mn', 'Exp_NP A/90mn']
PerfsL1.insert(0, "Date", Aujourdhui)
print(PerfsL1)
PerfsL12 = pd.read_csv('Ligue_1_Perfs.csv', index_col=0)
print(PerfsL12)
PerfsL1 = pd.concat([PerfsL1, PerfsL12], ignore_index = True)
print (PerfsL1)

I successfully managed to get both df individually which are sharing the same columns, but I can't merge them, getting

ValueError: no types given.

Do you have an idea where it could be coming from ?

EDIT Here are both dataframes:

'Ligue_1.csv'
 Date         Équipe  Used_players   age  Possesion  nb_matchs  ...  Exp_NP A  Exp_buts/90mn  Exp_Assists/90mn  Exp_B A/90mn  Exp_NoPenaltis/90mn  Exp_NP A/90mn
0   00:37:48        Ajaccio            18  29.1       34.5          2  ...       1.6           0.97              0.24          1.20                 0.57           0.81    
1   00:37:48         Angers            18  26.8       55.0          2  ...       5.9           1.78              1.18          2.96                 1.78           2.96    
2   00:37:48        Auxerre            15  29.4       39.5          2  ...       3.3           0.83              0.80          1.63                 0.83           1.63    
3   00:37:48          Brest            18  26.8       42.5          2  ...       5.0           1.67              1.23          2.90                 1.28           2.51    
4   00:37:48  Clermont Foot            18  27.8       48.5          2  ...       1.8           0.89              0.38          1.27                 0.50           0.88    
5   00:37:48           Lens            16  26.2       63.0          2  ...       5.6           1.92              1.29          3.21                 1.53           2.82    
6   00:37:48          Lille            18  27.2       65.0          2  ...       7.3           2.02              1.65          3.66                 2.02           3.66    
7   00:37:48        Lorient            14  25.8       36.0          1  ...       0.6           0.37              0.26          0.63                 0.37           0.63    
8   00:37:48           Lyon            15  26.0       68.0          1  ...       1.2           1.52              0.49          2.00                 0.73           1.22    
9   00:37:48      Marseille            17  26.9       55.0          2  ...       4.9           1.40              1.03          2.43                 1.40           2.43    
10  00:37:48         Monaco            19  24.8       40.5          2  ...       7.1           2.74              1.19          3.93                 2.35           3.54    
11  00:37:48    Montpellier            19  25.5       47.5          2  ...       3.2           0.93              0.66          1.59                 0.93           1.59    
12  00:37:48         Nantes            16  26.9       40.5          2  ...       3.9           1.37              0.60          1.97                 1.37           1.97    
13  00:37:48           Nice            18  25.9       54.0          2  ...       3.1           1.25              0.69          1.94                 0.86           1.55    
14  00:37:48      Paris S-G            18  27.6       60.0          2  ...       8.1           3.05              1.76          4.81                 2.27           4.03  


print(PerfsL1 = pd.read_html('https://fbref.com/fr/comps/13/stats/Statistiques-Ligue-1#all_stats_standard', header=1)[0])

Date         Équipe Used_players   age Possesion nb_matchs  ... Exp_NP A Exp_buts/90mn Exp_Assists/90mn Exp_B A/90mn Exp_NoPenaltis/90mn Exp_NP A/90mn
0   09:56:18        Ajaccio           18  29.1      34.5         2  ...      1.6          0.97             0.24         1.20                0.57          0.81
1   09:56:18         Angers           18  26.8      55.0         2  ...      5.9          1.78             1.18         2.96                1.78          2.96
2   09:56:18        Auxerre           15  29.4      39.5         2  ...      3.3          0.83             0.80         1.63                0.83          1.63
3   09:56:18          Brest           18  26.8      42.5         2  ...      5.0          1.67             1.23         2.90                1.28          2.51
4   09:56:18  Clermont Foot           18  27.8      48.5         2  ...      1.8          0.89             0.38         1.27                0.50          0.88
5   09:56:18           Lens           16  26.2      63.0         2  ...      5.6          1.92             1.29         3.21                1.53          2.82
6   09:56:18          Lille           18  27.2      65.0         2  ...      7.3          2.02             1.65         3.66                2.02          3.66
7   09:56:18        Lorient           14  25.8      36.0         1  ...      0.6          0.37             0.26         0.63                0.37          0.63
8   09:56:18           Lyon           15  26.0      68.0         1  ...      1.2          1.52             0.49         2.00                0.73          1.22
9   09:56:18      Marseille           17  26.9      55.0         2  ...      4.9          1.40             1.03         2.43                1.40          2.43
10  09:56:18         Monaco           19  24.8      40.5         2  ...      7.1          2.74             1.19         3.93                2.35          3.54
11  09:56:18    Montpellier           19  25.5      47.5         2  ...      3.2          0.93             0.66         1.59                0.93          1.59
12  09:56:18         Nantes           16  26.9      40.5         2  ...      3.9          1.37             0.60         1.97                1.37          1.97
13  09:56:18           Nice           18  25.9      54.0         2  ...      3.1          1.25             0.69         1.94                0.86          1.55

Thanks you for your support and have a great day !

CodePudding user response:

Please show a example of "Ligue_1_Perfs.csv".

CodePudding user response:

Your code should work.

Nevertheless, try this before the concat:

PerfsL1 = PerfsL1.reset_index()
PerfsL2 = PerfsL2.reset_index()
  • Related