Преобразуйте NSDate в NSString

df1

       Domain             Pattern Other Important Info
0  amazon.com              kindle                    a
1   apple.com               music                    b
2  amazon.com  subscribe-and-save                    c
3     xyz.com                                         

df2

        Domain                                    Url
0   google.com              https://google.com/kindle
1   google.com                    https://google.com/
2   amazon.com  https://amazon.com/subscribe-and-save
3   amazon.com                 https://amazon.com/abc
4  youtube.com              https://youtube.com/music
5   amazon.com                https:amazon.com/kindle

Основная цель - объединить два кадра данных на основе «домена», а также когда «шаблон» находится в « Веб-сайт».

df = df1.merge(df2, on='Domain')
df.loc[df.apply(lambda x: x.Pattern in x.Url, axis=1)]

Вывод

       Domain             Pattern Other Important Info  \
2  amazon.com              kindle                    a   
3  amazon.com  subscribe-and-save                    c   

                                     Url  
2                https:amazon.com/kindle  
3  https://amazon.com/subscribe-and-save  
251
задан Jon Schneider 7 November 2018 в 03:57
поделиться

2 ответа

Как насчет ...

NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"yyyy"];

//Optionally for time zone conversions
[formatter setTimeZone:[NSTimeZone timeZoneWithName:@"..."]];

NSString *stringFromDate = [formatter stringFromDate:myNSDateInstance];

//unless ARC is active
[formatter release];

Swift 4.2:

func stringFromDate(_ date: Date) -> String {
    let formatter = DateFormatter()
    formatter.dateFormat = "dd MMM yyyy HH:mm" //yyyy
    return formatter.string(from: date)
}
463
ответ дан 23 November 2019 в 02:53
поделиться

Если у вас нет NSDate -descriptionWithCalendarFormat: timeZone: locale: доступно (я не думаю, что iPhone / Cocoa Touch включает это), вам может понадобиться использовать strftime и monkey с некоторыми строками в стиле C Вы можете получить метку времени UNIX из NSDate , используя NSDate -timeIntervalSince1970 .

4
ответ дан 23 November 2019 в 02:53
поделиться
Другие вопросы по тегам:

Похожие вопросы: