Похожие чаты

Guys does assignment works in list comprehension for u ?

7 ответов

25 просмотров

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- Автор вопроса
Bread pup ▲⬤ ×▫︎
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- Автор вопроса
Bread pup ▲⬤ ×▫︎
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

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

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

а через ESC-код ?
Alexey Kulakov
29
30500 за редактор? )
Владимир
47
Чёт не понял, я ж правильной функцией воспользовался чтобы вывести отладочную информацию? но что-то она не ловится
notme
18
У меня есть функция где происходит это: write_bit(buffer, 1); write_bit(buffer, 0); write_bit(buffer, 1); write_bit(buffer, 1); write_bit(buffer, 1); w...
~
13
any reference of this implementation?
BitBuddha
29
Ⓐrtto, [4/23/24 7:02 PM] Please explain more fully how it is not working exactly, and what are the steps you are taking, and what error messages come or what happens. Ⓐrtto, ...
Ezza Kezza
2
sounds like people have lost their kaspa on tradeogre... does this mean tradeogre not trustworthy?
Ezza Kezza
15
Страшнейшая правда про списки ЦБ. С первых дней жизни P2P сферы, молодые человеки, начитавшись законодательной базы и "внутренних" документов, решили, что им противостоит сер...
Foxcool
3
Недавно Google Project Zero нашёл багу в SQLite с помощью LLM, о чём достаточно было шумно в определённых интернетах, которые сопровождались рассказами, что скоро всех "ибешни...
Alex Sherbakov
5
So much speculation in the last week. So much volatility in price. This is because Hedera has a GC that isn't using the network it's governing. Why aren't people asking why a...
Summit Seeker R
9
Карта сайта