Похожие чаты

Guys does assignment works in list comprehension for u ?

7 ответов

27 просмотров

Can you send some code so that I understand what you are talking about?

Dumbo- Автор вопроса
dog Ass
Can you send some code so that I understand what y...

thanks for ur reply Main goal: cast a date column in a Panda's dataframe to datetime64[ns] 1 of the steps I'm in involves list comprehension, and the operation involves .astype to cast the current column (that matches "time|period|date" to datetime64[ns] My questions are:: - if/how can u cast type in-place ? - If not, if/how can u do assignment inside a list comprehension ? I've tried the following, none works so far, either dtype not changed or syntax error

Dumbo- Автор вопроса
Dumbo
screenshot thanks for ur reply Main goal: cast a date column...

dataframe used: column_0_date column_1_cat column_2_float column_3_int column_4_cat column_5_cat column_6_date column_7_float 0 2020-12-03 Barbara 20.411797 4 sheep Madrid 2020-12-08 86.298482 1 2020-09-10 Michael 16.679344 7 sheep Marseille 2020-12-20 49.4705 2 2020-10-14 James 49.41644 6 shrimp Stockholm 2020-01-18 20.290111 3 2020-04-06 Barbara 58.621822 1 crab Denver 2020-01-19 6.201747 4 2020-09-09 Robert 54.523121 5 fish Madrid 2020-08-08 96.107839

Dumbo
screenshot thanks for ur reply Main goal: cast a date column...

You want a good ol for loop, not a list comprehension as what you want isn't a new list, but to change something in place

Dumbo- Автор вопроса
Link 🪈
You want a good ol for loop, not a list comprehens...

Ya haha I realized I was only doing it out of habit, even if it's sometimes unpythonic I will go regular loop here Tho I do be curious still whether we could actually make it work with list comprehension, using some trickery, voodoo magic or otherwise, for science 👀👀

Dumbo
Ya haha I realized I was only doing it out of habi...

It should work, what error are you getting?

Dumbo- Автор вопроса
Link 🪈
It should work, what error are you getting?

No error, but no change applied As I understand it most methods are not in place by default, working on copies instead So changes to the original dataframe won't "stick" unless u explicitly assign the changes to the original dataframe, or if the method has an inplace=True argument, or maybe copy=False .astype has the last one which I set but didn't seem to work

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

Обсуждают сегодня

Господа, а что сейчас вообще с рынком труда на делфи происходит? Какова ситуация?
Rꙮman Yankꙮvsky
29
А вообще, что может смущать в самой Julia - бы сказал, что нет единого стандартного подхода по многим моментам, поэтому многое выглядит как "хаки" и произвол. Короче говоря, с...
Viktor G.
2
@Benzenoid can you tell me the easiest, and safest way to bu.y HEX now?
Živa Žena
20
This is a question from my wife who make a fortune with memes 😂😂 About the Migration and Tokens: 1. How will the old tokens be migrated to the new $LGCYX network? What is th...
🍿 °anton°
2
30500 за редактор? )
Владимир
47
а через ESC-код ?
Alexey Kulakov
29
What is the Dex situation? Agora team started with the Pnetwork for their dex which helped them both with integration. It’s completed but as you can see from the Pnetwork ann...
Ben
1
Гайс, вопрос для разносторонее развитых: читаю стрим с юарта, нада выделять с него фреймы с определенной структурой, если ли чо готовое, или долбаться с ринг буффером? нада у...
Vitaly
9
Anyone knows where there are some instructions or discort about failed bridge transactions ?
Jochem
21
@lozuk how do I get my phex copies of my ehex from a atomic wallet, to move to my rabby?
Justfrontin 👀
11
Карта сайта