data-cleaning

Test column for special characters or only characters / numbers

♀尐吖头ヾ 提交于 2021-01-24 14:10:31
问题 I tried finding special characters using generic regex attributes and NOT LIKE clause but have been getting confusing results. The research suggested that it does not work the way it works in SQL Server or elsewhere. For finding if there is any character For finding if there is any number For finding if there is any special character like '%[^0-9]%' or '%[^a-Z]%' does not work very well when finding if non-numeric data is available and if non-alphabetical data is present, respectively SELECT

Test column for special characters or only characters / numbers

走远了吗. 提交于 2021-01-24 14:09:10
问题 I tried finding special characters using generic regex attributes and NOT LIKE clause but have been getting confusing results. The research suggested that it does not work the way it works in SQL Server or elsewhere. For finding if there is any character For finding if there is any number For finding if there is any special character like '%[^0-9]%' or '%[^a-Z]%' does not work very well when finding if non-numeric data is available and if non-alphabetical data is present, respectively SELECT

Test column for special characters or only characters / numbers

假如想象 提交于 2021-01-24 14:01:29
问题 I tried finding special characters using generic regex attributes and NOT LIKE clause but have been getting confusing results. The research suggested that it does not work the way it works in SQL Server or elsewhere. For finding if there is any character For finding if there is any number For finding if there is any special character like '%[^0-9]%' or '%[^a-Z]%' does not work very well when finding if non-numeric data is available and if non-alphabetical data is present, respectively SELECT

Apply a user defined function to a list of data frames

淺唱寂寞╮ 提交于 2020-12-15 06:37:20
问题 I have a series of data frames structured similarly to this: df <- data.frame(x = c('notes','year',1995:2005), y = c(NA,'value',11:21)) df2 <- data.frame(x = c('notes','year',1995:2005), y = c(NA,'value',50:60)) In order to clean them I wrote a user defined function with a set of cleaning steps: clean <- function(df){ colnames(df) <- df[2,] df <- df[grep('^[0-9]{4}', df$year),] return(df) } I'd now like to put my data frames in a list: df_list <- list(df,df2) and clean them all at once. I

How to convert values like '2+3' in a Python Pandas column to its aggregated value

会有一股神秘感。 提交于 2020-12-12 03:29:38
问题 I have a column in a DataFrame named fatalities in which few of the values are like below: data[''fatalities']= [1, 4, , 10, 1+8, 5, 2+9, , 16, 4+5] I want the values of like '1+8', '2+9', etc to be converted to its aggregated value i.e, data[''fatalities']= [1, 4, , 10, 9, 5, 11, , 16, 9] I not sure how to write a code to perform above aggregation for one of the column in pandas DataFrame in Python. But when I tried with the below code its throwing an error. def addition(col): col= col.split

How to convert values like '2+3' in a Python Pandas column to its aggregated value

折月煮酒 提交于 2020-12-12 03:27:51
问题 I have a column in a DataFrame named fatalities in which few of the values are like below: data[''fatalities']= [1, 4, , 10, 1+8, 5, 2+9, , 16, 4+5] I want the values of like '1+8', '2+9', etc to be converted to its aggregated value i.e, data[''fatalities']= [1, 4, , 10, 9, 5, 11, , 16, 9] I not sure how to write a code to perform above aggregation for one of the column in pandas DataFrame in Python. But when I tried with the below code its throwing an error. def addition(col): col= col.split

custom validation error for two fields unique together django

[亡魂溺海] 提交于 2020-07-23 06:15:18
问题 i want to write my own validation error , for two fields unique together class MyModel(models.Model): name = models.CharField(max_length=20) second_field = models.CharField(max_length=10) #others class Meta: unique_together = ('name','second_field') and my forms.py class MyModelForm(forms.ModelForm): class Meta: model = MyModel fields = '__all__' error_messages= {#how to write my own validation error whenever `name and second_field` are unique together }: how to write my own validation error

custom validation error for two fields unique together django

左心房为你撑大大i 提交于 2020-07-23 06:14:20
问题 i want to write my own validation error , for two fields unique together class MyModel(models.Model): name = models.CharField(max_length=20) second_field = models.CharField(max_length=10) #others class Meta: unique_together = ('name','second_field') and my forms.py class MyModelForm(forms.ModelForm): class Meta: model = MyModel fields = '__all__' error_messages= {#how to write my own validation error whenever `name and second_field` are unique together }: how to write my own validation error