There is a pandas df frame which has 4 columns – serverName,ip-address,key,value. The key value pairs have various entries and hence the servername,ip-address are having no entries
The assign function is not accepting ip-address, while I try the same with serverName, it is okay.
Is eiphen (-) being not accepted as part of below some kind of pandas or python limitation? I wanted to make it generic column header which is coming from variables and hence the header is ‘ip-address’ and also reason do not want to use a new column entry. if this is limitation need to work on all headers which may come with eiphen(-)
>>> data3 = data2.assign(ip-address=data2['ip-address'].ffill().astype(str)).loc[data2['ip-address'].isna()]
File "<stdin>", line 1
data3 = data2.assign(ip-address=data2['ip-address'].ffill().astype(str)).loc[data2['ip-address'].isna()]
^^^^^^^^^^^
SyntaxError: expression cannot contain assignment, perhaps you meant "=="?
>>> data3 = data2.assign(ipaddress=data2['ip-address'].ffill().astype(str)).loc[data2['ip-address'].isna()]
I expected that the names with eiphen will be accepted.
PythonVivek is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.