Python Forum
TypeError: sequence item 0: expected str instance, float found Error Query
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
TypeError: sequence item 0: expected str instance, float found Error Query
#1
Hi there,

I have the following, first part of a Python Pandas Code :-

import pandas as pd
pd.chained_assignment=None
         
data = pd.read_csv(r'C:\Users\Admin\Desktop\BBMF2011.csv')      

pd.options.display.max_rows = 1000   
pd.options.display.max_columns = 1000
 
df = pd.DataFrame(data, columns= ['Venue','A/C','D/FP/T/P','Date','Bid',"Dur'"])
#df[(df['Venue'].str.contains('[a-zA-Z]') & (df['D/FP/T/P'].str.contains('DISPLAY') & df['A/C'].str.contains("DHS|DAK|HS|SPIT")) & (df['A/C'] != 'LHS') & (df['A/C'] != 'LANC'))] 
#df["Date"].fillna("No Date", inplace = True)   
df["Date"].fillna(method='ffill', inplace = True)

df['A/C'].unique().tolist()  
rename_map = {
    'DAK': 'D',
    'SPIT': 'S',
    'LANC': 'L',
    'HURRI': 'H',
    'PARA': 'P'
}
df['A/C std'] = df['A/C'].replace(rename_map)
print(df['A/C std'].unique().tolist())
print("=======")  

#selected = df.loc[df['D/FP/T/P'] == 'FLYPAST']
selected = df.loc[df['D/FP/T/P'].isin(['DISPLAY', 'FLYPAST', 'FP', 'D'])]
#selected = df.loc[df['A/C'].isin(['DS', 'DH', 'DHS', 'SD', 'HSD'])]
 
df1=df
groupby_venue_date = selected.groupby(['Venue', 'Bid', 'Date', 'D/FP/T/P']) 
aircraft = groupby_venue_date['A/C std'].apply(''.join).rename('Aircraft-Allocation')
def sorted_string(s):
    return ''.join(sorted(s))   
def remove_duplicate_chars(s):
    return ''.join(set(s))
    
    
#####################
#####################
#####################
#####################
    
    
df=pd.DataFrame(aircraft)
#print(df) #original df
      
     
indexNames = df[~df['Aircraft-Allocation'].str.contains('D',na=False)].index
df.drop(indexNames , inplace=True)
#print(df)#prints all rows having D and removes remaining rows
    
df['Aircraft-Allocation']=df['Aircraft-Allocation'].replace(to_replace='SD', value='DS')
df['Aircraft-Allocation']=df['Aircraft-Allocation'].replace(to_replace=['HSD','HDS','SDH', 'SHSD'], value='DHS')
#print(df)#replaces the SD with DS and HSD,HDS and SHSD with DHS
      
   
     
df = df.drop(df[df['Aircraft-Allocation'] == 'D'].index)#remove value that match letter D
df = df.drop(df[df['Aircraft-Allocation'] == 'DD'].index)
df = df.drop(df[df['Aircraft-Allocation'] == 'DL'].index)
df = df.drop(df[df['Aircraft-Allocation'] == 'LD'].index)
df = df.drop(df[df['Aircraft-Allocation'] == 'LDS'].index)
df = df.drop(df[df['Aircraft-Allocation'] == 'LSSD'].index)
#df = df.drop(df[df['Aircraft-combined'] != 'D'].index)#if need the rows that match only letter D in selected dataframe column
   
   
   
#column names before alignment
#print("column names: before change  ", list(df.columns.values.tolist()))
#print("=======")
#print(df)
#print("=======")  
    
   
#to fix column name alignment 
df.to_csv(r'C:\Users\Admin\Desktop\BBMF Schedules And Master Forum Thread Texts\tempfiletest7.csv')
df = pd.read_csv(r'C:\Users\Admin\Desktop\BBMF Schedules And Master Forum Thread Texts\tempfiletest7.csv',names=['Venue','Bid','Date','D/FP/T/P','Aircraft-Allocation'], header=0 )
   
   
#column names before alignment
#print("column names:  after change ",list(df.columns.values.tolist()))
#print("=======")
#print(df)
#print("=======")
 
 
###My code Starts here
 
x,y,z=df['Venue'],df['Bid'],df['Date']
x=list(x)
y=list(y)
z=list(z)
import numpy as np
 
h=np.array(y)
np.unique(h)
 
yy=[]
for jj in y:
    yy.append(str(jj))
 
t= df1['Venue'].isin(x)
df2=df1[t]
df2
 
g=df2['Date'].isin(z)
df3=df2[g]
df3=pd.DataFrame(df3)
 
df3
 
g=df3['Bid'].isin(yy)
df4=df3[g]
df4=pd.DataFrame(df4)
 
 
df4
 
column_names = ['Venue','A/C','D/FP/T/P','Date','Bid',"Dur'",'Aircraft-Allocation']
dff = pd.DataFrame(columns = column_names)
dff.to_csv(r'C:\Users\Admin\Desktop\BBMF Schedules And Master Forum Thread Texts\tempfiletest7.csv')
dff = pd.read_csv(r'C:\Users\Admin\Desktop\BBMF Schedules And Master Forum Thread Texts\tempfiletest7.csv',names=['Venue','A/C','D/FP/T/P','Date','Bid',"Dur'",'Aircraft-Allocation'], header=0 )
df4
df4.to_csv(r'C:\Users\Admin\Desktop\BBMF Schedules And Master Forum Thread Texts\tempfiletest7.csv')
df4 = pd.read_csv(r'C:\Users\Admin\Desktop\BBMF Schedules And Master Forum Thread Texts\tempfiletest7.csv',names=['Venue','A/C','D/FP/T/P','Date','Bid',"Dur'",'Aircraft-Allocation'], header=0 )


for x in range(0,len(df4)):
    y=x+1
    z=x+2
    try:
        if ((((df4.iloc[x][6]))=='DSH') or (((df4.iloc[x][6]))=='SD') or (((df4.iloc[x][6]))=='DS') or (((df4.iloc[x][6]))=='HSD') or (((df4.iloc[x][6]))=='HDS') or (((df4.iloc[x][6]))=='SHSD') or (((df4.iloc[x][6]))=='DHS')):
            dff3 ={'Venue':df4.iloc[x][0],'A/C':df4.iloc[x][1],'D/FP/T/P':df4.iloc[x][2],'Date':df4.iloc[x][3],'Bid':df4.iloc[x][4],"Dur'":df4.iloc[x][5],'Aircraft-Allocation':df4.iloc[x][6]}
            dff = dff.append(dff3,ignore_index=True)
             
             
        elif ((df4.iloc[x][0]==df4.iloc[y][0]==df4.iloc[z][0]) and (df4.iloc[x][3]==df4.iloc[y][3]==df4.iloc[z][3])  ):
            sidhu=df4.iloc[x][6]+df4.iloc[y][6]+df4.iloc[z][6]
            dff4 ={'Venue':df4.iloc[x][0],'A/C':df4.iloc[x][1],'D/FP/T/P':df4.iloc[x][2],'Date':df4.iloc[x][3],'Bid':df4.iloc[x][4],"Dur'":df4.iloc[x][5],'Aircraft-Allocation':sidhu}

            dff5 ={'Venue':df4.iloc[y][0],'A/C':df4.iloc[y][1],'D/FP/T/P':df4.iloc[y][2],'Date':df4.iloc[y][3],'Bid':df4.iloc[y][4],"Dur'":df4.iloc[y][5],'Aircraft-Allocation':sidhu}
            dff6 ={'Venue':df4.iloc[z][0],'A/C':df4.iloc[z][1],'D/FP/T/P':df4.iloc[z][2],'Date':df4.iloc[z][3],'Bid':df4.iloc[z][4],"Dur'":df4.iloc[z][5],'Aircraft-Allocation':sidhu}

            dff = dff.append(dff4,ignore_index=True)
            dff = dff.append(dff5,ignore_index=True)
            dff= dff.append(dff6,ignore_index=True)
            
            
            
        
        elif ((df4.iloc[x][3]==df4.iloc[y][3]) and (df4.iloc[x][0]==df4.iloc[y][0])):
            sidhu=df4.iloc[x][6]+df4.iloc[y][6]
            dff1 = {'Venue':df4.iloc[x][0],'A/C':df4.iloc[x][1],'D/FP/T/P':df4.iloc[x][2],'Date':df4.iloc[x][3],'Bid':df4.iloc[x][4],"Dur'":df4.iloc[x][5],'Aircraft-Allocation':sidhu}
            dff2 = {'Venue':df4.iloc[y][0],'A/C':df4.iloc[y][1],'D/FP/T/P':df4.iloc[y][2],'Date':df4.iloc[y][3],'Bid':df4.iloc[y][4],"Dur'":df4.iloc[y][5],'Aircraft-Allocation':sidhu}
            dff = dff.append(dff1,ignore_index=True)
            dff = dff.append(dff2,ignore_index=True)

            
        
             
         
             
              
        else:
            pass
    except Exception:
        pass
x=x-1
y=y-1
if((df4.iloc[x][3]==df4.iloc[y][3]) and (df4.iloc[x][0]==df4.iloc[y][0])):
    sidhu=df4.iloc[x][6]+df4.iloc[y][6]
    dff7 = {'Venue':df4.iloc[x][0],'A/C':df4.iloc[x][1],'D/FP/T/P':df4.iloc[x][2],'Date':df4.iloc[x][3],'Bid':df4.iloc[x][4],"Dur'":df4.iloc[x][5],'Aircraft-Allocation':sidhu}
    dff8 = {'Venue':df4.iloc[y][0],'A/C':df4.iloc[y][1],'D/FP/T/P':df4.iloc[y][2],'Date':df4.iloc[y][3],'Bid':df4.iloc[y][4],"Dur'":df4.iloc[y][5],'Aircraft-Allocation':sidhu}         
    dff = dff.append(dff7,ignore_index=True)
    dff = dff.append(dff8,ignore_index=True)
        
        
dff['Aircraft-Allocation']=dff['Aircraft-Allocation'].replace(to_replace='SD', value='DS')
dff['Aircraft-Allocation']=dff['Aircraft-Allocation'].replace(to_replace='SSD', value='DSS')
dff['Aircraft-Allocation']=dff['Aircraft-Allocation'].replace(to_replace=['HSD','HDS','SDH', 'SHSD'], value='DHS')
dff['Dakota And Fighters In The Same Slot']='Yes'




for x in range(0,len(dff)):
    y=x+1
    try:
        if ((dff.iloc[x][3]==dff.iloc[y][3]) and (dff.iloc[x][0]==dff.iloc[y][0])):
            if dff.iloc[x][5]==dff.iloc[y][5]:
                dff['Dakota And Fighters In The Same Slot'][x]='Yes'
                dff['Dakota And Fighters In The Same Slot'][y]='Yes'
                 
            else:
                dff['Dakota And Fighters In The Same Slot'][x]='No'
                dff['Dakota And Fighters In The Same Slot'][y]='No'
                 
                 
             
 
             
         
             
              
        else:
            continue
    except Exception:
        break
dff=dff.drop('A/C',axis=1)
dff=dff.drop_duplicates(subset=['Venue','Date','Bid','Dakota And Fighters In The Same Slot'], keep='first', inplace=False)
dff=dff.drop_duplicates(subset=None, keep='first', inplace=False)
#dff.loc[6,"Dur'"]=10

dff = dff.drop(dff[dff['Aircraft-Allocation'] == 'DLHS'].index)
dff = dff.drop(dff[dff['Aircraft-Allocation'] == 'DLS'].index)
dff = dff.drop(dff[dff['Aircraft-Allocation'] == 'HSL'].index)
dff = dff.drop(dff[dff['Aircraft-Allocation'] == 'LHSD'].index)

dff["Dur'"]= pd.to_datetime(dff["Dur'"],format='%M').apply(pd.Timestamp)
dff["Dur'"] = pd.to_datetime(dff["Dur'"], format='%H:%M:%S').dt.time
dff['Date']= pd.to_datetime(dff['Date'],format='%d-%b')
dff['Date']= pd.to_datetime(dff['Date']).dt.strftime('%d-%m-2011')

dff=dff.fillna('--')

dff.to_csv(r'C:\Users\Admin\Desktop\BBMF Schedules And Master Forum Thread Texts\BBMF-2011-Code-2021-Test.csv')

df11=dff

df11.reset_index(drop=True, inplace=True)

df11
Which gives the following Error :-

Error:
TypeError: sequence item 0: expected str instance, float found
Pointing to the following part of that Code :-

     30 df1=df
     31 groupby_venue_date = selected.groupby(['Venue', 'Bid', 'Date', 'D/FP/T/P'])
---> 32 aircraft = groupby_venue_date['A/C std'].apply(''.join).rename('Aircraft-Allocation')
     33 def sorted_string(s):
     34     return ''.join(sorted(s))
I am unsure, what is causing the Error, and how to fix it ? Could someone tell me, what might be causing the Error, and how I can fix it ?

I have attached the needed BBMF2011.csv File, to this thread.

Any help would be much appreciated.

Best Regards

Eddie Winch

Attached Files

.csv   BBMF2011.csv (Size: 136.99 KB / Downloads: 235)
Reply
#2
Here is the rest of the Code :-

import pandas as pd
pd.chained_assignment=None
         
data = pd.read_csv(r'C:\Users\Admin\Desktop\BBMF2011.csv')      

pd.options.display.max_rows = 1000   
pd.options.display.max_columns = 1000
 
df = pd.DataFrame(data, columns= ['Venue','A/C','D/FP/T/P','Date','Bid',"Dur'"])
#df[(df['Venue'].str.contains('[a-zA-Z]') & (df['D/FP/T/P'].str.contains('DISPLAY') & df['A/C'].str.contains("DHS|DAK|HS|SPIT")) & (df['A/C'] != 'LHS') & (df['A/C'] != 'LANC'))] 
#df["Date"].fillna("No Date", inplace = True)   
df["Date"].fillna(method='ffill', inplace = True)

df['A/C'].unique().tolist()  
rename_map = {
    'DAK': 'D',
    'SPIT': 'S',
    'LANC': 'L',
    'HURRI': 'H',
    'PARA': 'P'
}
df['A/C std'] = df['A/C'].replace(rename_map)
print(df['A/C std'].unique().tolist())
print("=======")  

#selected = df.loc[df['D/FP/T/P'] == 'FLYPAST']
selected = df.loc[df['D/FP/T/P'].isin(['DISPLAY', 'FLYPAST', 'FP', 'D'])]
#selected = df.loc[df['A/C'].isin(['DS', 'DH', 'DHS', 'SD', 'HSD'])]
 
df1=df
groupby_venue_date = selected.groupby(['Venue', 'Bid', 'Date', 'D/FP/T/P']) 
aircraft = groupby_venue_date['A/C std'].apply(''.join).rename('Aircraft-Allocation')
def sorted_string(s):
    return ''.join(sorted(s))   
def remove_duplicate_chars(s):
    return ''.join(set(s))
    
    
#####################
#####################
#####################
#####################
    
    
df=pd.DataFrame(aircraft)
#print(df) #original df
      
     
indexNames = df[~df['Aircraft-Allocation'].str.contains('D',na=False)].index
df.drop(indexNames , inplace=True)
#print(df)#prints all rows having D and removes remaining rows
    
df['Aircraft-Allocation']=df['Aircraft-Allocation'].replace(to_replace='SD', value='DS')
df['Aircraft-Allocation']=df['Aircraft-Allocation'].replace(to_replace=['HSD','HDS','SDH', 'SHSD'], value='DHS')
#print(df)#replaces the SD with DS and HSD,HDS and SHSD with DHS
      
   
     
#df = df.drop(df[df['Aircraft-Allocation'] == 'D'].index)#remove value that match letter D
df = df.drop(df[df['Aircraft-Allocation'] == 'DD'].index)
df = df.drop(df[df['Aircraft-Allocation'] == 'DL'].index)
df = df.drop(df[df['Aircraft-Allocation'] == 'LD'].index)
df = df.drop(df[df['Aircraft-Allocation'] == 'LDS'].index)
df = df.drop(df[df['Aircraft-Allocation'] == 'LSSD'].index)
df = df.drop(df[df['Aircraft-Allocation'] != 'D'].index)#if need the rows that match only letter D in selected dataframe column
   
   
   
#column names before alignment
#print("column names: before change  ", list(df.columns.values.tolist()))
#print("=======")
#print(df)
#print("=======")  
    
   
#to fix column name alignment 
df.to_csv(r'C:\Users\Admin\Desktop\BBMF Schedules And Master Forum Thread Texts\tempfiletest8.csv')
df = pd.read_csv(r'C:\Users\Admin\Desktop\BBMF Schedules And Master Forum Thread Texts\tempfiletest8.csv',names=['Venue','Bid','Date','D/FP/T/P','Aircraft-Allocation'], header=0 )
   
   
#column names before alignment
#print("column names:  after change ",list(df.columns.values.tolist()))
#print("=======")
#print(df)
#print("=======")
 
 
###My code Starts here
 
x,y,z=df['Venue'],df['Bid'],df['Date']
x=list(x)
y=list(y)
z=list(z)
import numpy as np
 
h=np.array(y)
np.unique(h)
 
yy=[]
for jj in y:
    yy.append(str(jj))
 
t= df1['Venue'].isin(x)
df2=df1[t]
df2
 
g=df2['Date'].isin(z)
df3=df2[g]
df3=pd.DataFrame(df3)
 
df3
 
g=df3['Bid'].isin(yy)
df4=df3[g]
df4=pd.DataFrame(df4)
 
 
df4
 
column_names = ['Venue','A/C','D/FP/T/P','Date','Bid',"Dur'",'Aircraft-Allocation']
dff = pd.DataFrame(columns = column_names)
dff.to_csv(r'C:\Users\Admin\Desktop\BBMF Schedules And Master Forum Thread Texts\tempfiletest8.csv')
dff = pd.read_csv(r'C:\Users\Admin\Desktop\BBMF Schedules And Master Forum Thread Texts\tempfiletest8.csv',names=['Venue','A/C','D/FP/T/P','Date','Bid',"Dur'",'Aircraft-Allocation'], header=0 )
df4
df4.to_csv(r'C:\Users\Admin\Desktop\BBMF Schedules And Master Forum Thread Texts\tempfiletest8.csv')
df4 = pd.read_csv(r'C:\Users\Admin\Desktop\BBMF Schedules And Master Forum Thread Texts\tempfiletest8.csv',names=['Venue','A/C','D/FP/T/P','Date','Bid',"Dur'",'Aircraft-Allocation'], header=0 )


for x in range(0,len(df4)):
    y=x+1
    z=x+2
    try:
        if ((((df4.iloc[x][6]))=='DSH') or (((df4.iloc[x][6]))=='SD') or (((df4.iloc[x][6]))=='DS') or (((df4.iloc[x][6]))=='HSD') or (((df4.iloc[x][6]))=='HDS') or (((df4.iloc[x][6]))=='SHSD') or (((df4.iloc[x][6]))=='DHS') or (((df4.iloc[x][6]))=='D')):
            dff3 ={'Venue':df4.iloc[x][0],'A/C':df4.iloc[x][1],'D/FP/T/P':df4.iloc[x][2],'Date':df4.iloc[x][3],'Bid':df4.iloc[x][4],"Dur'":df4.iloc[x][5],'Aircraft-Allocation':df4.iloc[x][6]}
            dff = dff.append(dff3,ignore_index=True)
             
             
        elif ((df4.iloc[x][0]==df4.iloc[y][0]==df4.iloc[z][0]) and (df4.iloc[x][3]==df4.iloc[y][3]==df4.iloc[z][3])  ):
            sidhu=df4.iloc[x][6]+df4.iloc[y][6]+df4.iloc[z][6]
            dff4 ={'Venue':df4.iloc[x][0],'A/C':df4.iloc[x][1],'D/FP/T/P':df4.iloc[x][2],'Date':df4.iloc[x][3],'Bid':df4.iloc[x][4],"Dur'":df4.iloc[x][5],'Aircraft-Allocation':sidhu}

            dff5 ={'Venue':df4.iloc[y][0],'A/C':df4.iloc[y][1],'D/FP/T/P':df4.iloc[y][2],'Date':df4.iloc[y][3],'Bid':df4.iloc[y][4],"Dur'":df4.iloc[y][5],'Aircraft-Allocation':sidhu}
            dff6 ={'Venue':df4.iloc[z][0],'A/C':df4.iloc[z][1],'D/FP/T/P':df4.iloc[z][2],'Date':df4.iloc[z][3],'Bid':df4.iloc[z][4],"Dur'":df4.iloc[z][5],'Aircraft-Allocation':sidhu}

            dff = dff.append(dff4,ignore_index=True)
            dff = dff.append(dff5,ignore_index=True)
            dff= dff.append(dff6,ignore_index=True)
            
            
            
        
        elif ((df4.iloc[x][3]==df4.iloc[y][3]) and (df4.iloc[x][0]==df4.iloc[y][0])):
            sidhu=df4.iloc[x][6]+df4.iloc[y][6]
            dff1 = {'Venue':df4.iloc[x][0],'A/C':df4.iloc[x][1],'D/FP/T/P':df4.iloc[x][2],'Date':df4.iloc[x][3],'Bid':df4.iloc[x][4],"Dur'":df4.iloc[x][5],'Aircraft-Allocation':sidhu}
            dff2 = {'Venue':df4.iloc[y][0],'A/C':df4.iloc[y][1],'D/FP/T/P':df4.iloc[y][2],'Date':df4.iloc[y][3],'Bid':df4.iloc[y][4],"Dur'":df4.iloc[y][5],'Aircraft-Allocation':sidhu}
            dff = dff.append(dff1,ignore_index=True)
            dff = dff.append(dff2,ignore_index=True)

            
        
             
         
             
              
        else:
            pass
    except Exception:
        pass
x=x-1
y=y-1
if((df4.iloc[x][3]==df4.iloc[y][3]) and (df4.iloc[x][0]==df4.iloc[y][0])):
    sidhu=df4.iloc[x][6]+df4.iloc[y][6]
    dff7 = {'Venue':df4.iloc[x][0],'A/C':df4.iloc[x][1],'D/FP/T/P':df4.iloc[x][2],'Date':df4.iloc[x][3],'Bid':df4.iloc[x][4],"Dur'":df4.iloc[x][5],'Aircraft-Allocation':sidhu}
    dff8 = {'Venue':df4.iloc[y][0],'A/C':df4.iloc[y][1],'D/FP/T/P':df4.iloc[y][2],'Date':df4.iloc[y][3],'Bid':df4.iloc[y][4],"Dur'":df4.iloc[y][5],'Aircraft-Allocation':sidhu}         
    dff = dff.append(dff7,ignore_index=True)
    dff = dff.append(dff8,ignore_index=True)
        
        
dff['Aircraft-Allocation']=dff['Aircraft-Allocation'].replace(to_replace='SD', value='DS')
dff['Aircraft-Allocation']=dff['Aircraft-Allocation'].replace(to_replace='SSD', value='DSS')
dff['Aircraft-Allocation']=dff['Aircraft-Allocation'].replace(to_replace=['HSD','HDS','SDH', 'SHSD'], value='DHS')
dff['Dakota And Fighters In The Same Slot']='--'




for x in range(0,len(dff)):
    y=x+1
    try:
        if ((dff.iloc[x][3]==dff.iloc[y][3]) and (dff.iloc[x][0]==dff.iloc[y][0])):
            if dff.iloc[x][5]==dff.iloc[y][5]:
                dff['Dakota And Fighters In The Same Slot'][x]='Yes'
                dff['Dakota And Fighters In The Same Slot'][y]='Yes'
                 
            else:
                dff['Dakota And Fighters In The Same Slot'][x]='No'
                dff['Dakota And Fighters In The Same Slot'][y]='No'
                 
                 
             
 
             
         
             
              
        else:
            continue
    except Exception:
        break
dff=dff.drop('A/C',axis=1)
#dff=dff.drop_duplicates(subset=['Venue','Date','Bid','Dakota And Fighters In The Same Slot'], keep='first', inplace=False)
dff=dff.drop_duplicates(subset=['Venue','Date'], keep='first', inplace=False)
dff=dff.drop_duplicates(subset=None, keep='first', inplace=False)
#dff.loc[6,"Dur'"]=10

dff = dff.drop(dff[dff['Aircraft-Allocation'] == 'DLHS'].index)
dff = dff.drop(dff[dff['Aircraft-Allocation'] == 'DLS'].index)
dff = dff.drop(dff[dff['Aircraft-Allocation'] == 'HSL'].index)
dff = dff.drop(dff[dff['Aircraft-Allocation'] == 'LHSD'].index)

dff["Dur'"]= pd.to_datetime(dff["Dur'"],format='%M').apply(pd.Timestamp)
dff["Dur'"] = pd.to_datetime(dff["Dur'"], format='%H:%M:%S').dt.time
dff['Date']= pd.to_datetime(dff['Date'],format='%d-%b')
dff['Date']= pd.to_datetime(dff['Date']).dt.strftime('%d-%m-2011')

dff=dff.fillna('--')

dff.to_csv(r'C:\Users\Admin\Desktop\BBMF Schedules And Master Forum Thread Texts\BBMF-2011-Code-2021-Test2.csv')

df12=dff

df12.reset_index(drop=True, inplace=True)

df12
dff = pd.concat([df12, df11], axis=0)
dff.loc[:,'Date'] = pd.to_datetime(dff.loc[:, 'Date'], format='%d-%m-%Y')

dff=dff.sort_values(by=['Date'])

dff['Date']= pd.to_datetime(dff['Date']).dt.strftime('%d-%m-%Y')

dff = dff.loc[(~dff['Venue'].str.contains('CNX|cnx'))]

dff.reset_index(drop=True, inplace=True)

dff
Eddie )
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  error in class: TypeError: 'str' object is not callable akbarza 2 449 Dec-30-2023, 04:35 PM
Last Post: deanhystad
  file open "file not found error" shanoger 8 946 Dec-14-2023, 08:03 AM
Last Post: shanoger
  boto3 - Error - TypeError: string indices must be integers kpatil 7 1,184 Jun-09-2023, 06:56 PM
Last Post: kpatil
  TypeError: 'float' object is not callable #1 isdito2001 1 1,046 Jan-21-2023, 12:43 AM
Last Post: Yoriz
  Module Not Found Error bitoded 4 1,346 Jan-01-2023, 09:08 AM
Last Post: bitoded
  TypeError: 'float' object is not callable TimofeyKolpakov 3 1,373 Dec-04-2022, 04:58 PM
Last Post: TimofeyKolpakov
  Error TypeError: output_type_handler() takes 2 positional arguments but 6 were given paulo79 1 1,858 Oct-17-2022, 06:29 PM
Last Post: paulo79
  File not found error saisankalpj 10 3,699 Jul-04-2022, 07:57 AM
Last Post: saisankalpj
  TypeError: float() argument must be a string or a number, not 'list' Anldra12 2 4,764 Jul-01-2022, 01:23 PM
Last Post: deanhystad
  "<class 'typeerror'>: don't know how to convert" error GiggsB 3 3,241 Feb-28-2022, 06:45 PM
Last Post: GiggsB

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020