Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Welcome to Software Development on Codidact!

Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.

Post History

50%
+1 −1
Q&A Separate digits of a number in groups with different sizes

I found a way how to fix it after I debug. It was only using the last used row because there was nothing to check that I want to edit only the current row. That's why I decide to use at for index,...

posted 2y ago by sfrow‭  ·  edited 2y ago by Alexei‭

Answer
#4: Post edited by user avatar Alexei‭ · 2021-11-09T06:05:33Z (over 2 years ago)
removed the additional question from the answer
  • Hi, I have one more question, because I do something wrong. If you notice the last column new Value is getting only from the last row. Which is ending with 416. Somehow I want inside of this for to update and create the new column to contain for each row the updated pattern.
  • ![Image alt text](https://software.codidact.com/uploads/1CxdEXsPMXCqH8HGU9aPAJLF)
  • **[EDIT]**
  • I found a way how to fix it after I debug. It was only using the last used row, because there was nothing to check that I want to edit only the current row. That's why I decide to use `at`
  • ```Python
  • for index, row in priceListTest.iterrows():
  • #print(index,row)
  • def get_slices(n, sizes, n_digits=11):
  • for size in sizes:
  • n_digits -= size
  • val, n = divmod(n, 10 ** n_digits)
  • yield f'{val:0{size}}'
  • n = row['Парт номер']
  • newVar = (' '.join(get_slices(n, [2, 2, 1, 3, 3])))
  • priceListTest.at[index,['New Value']] = newVar
  • print("after changes")
  • print(priceListTest)
  • I found a way how to fix it after I debug. It was only using the last used row because there was nothing to check that I want to edit only the current row. That's why I decide to use `at`
  • ```Python
  • for index, row in priceListTest.iterrows():
  • #print(index,row)
  • def get_slices(n, sizes, n_digits=11):
  • for size in sizes:
  • n_digits -= size
  • val, n = divmod(n, 10 ** n_digits)
  • yield f'{val:0{size}}'
  • n = row['Парт номер']
  • newVar = (' '.join(get_slices(n, [2, 2, 1, 3, 3])))
  • priceListTest.at[index,['New Value']] = newVar
  • print("after changes")
  • print(priceListTest)
#3: Post edited by user avatar sfrow‭ · 2021-11-08T19:16:23Z (over 2 years ago)
  • Hi, I have one more question, because I do something wrong. If you notice the last column new Value is getting only from the last row. Which is ending with 416. Somehow I want inside of this for to update and create the new column to contain for each row the updated pattern.
  • ![Image alt text](https://software.codidact.com/uploads/1CxdEXsPMXCqH8HGU9aPAJLF)
  • I found a way how to fix it after I debug. It was only using the last used row, because there was nothing to check that I want to edit only the current row. That's why I decide to use `at`
  • ```Python
  • for index, row in priceListTest.iterrows():
  • #print(index,row)
  • def get_slices(n, sizes, n_digits=11):
  • for size in sizes:
  • n_digits -= size
  • val, n = divmod(n, 10 ** n_digits)
  • yield f'{val:0{size}}'
  • n = row['Парт номер']
  • newVar = (' '.join(get_slices(n, [2, 2, 1, 3, 3])))
  • priceListTest.at[index,['New Value']] = newVar
  • print("after changes")
  • print(priceListTest)
  • Hi, I have one more question, because I do something wrong. If you notice the last column new Value is getting only from the last row. Which is ending with 416. Somehow I want inside of this for to update and create the new column to contain for each row the updated pattern.
  • ![Image alt text](https://software.codidact.com/uploads/1CxdEXsPMXCqH8HGU9aPAJLF)
  • **[EDIT]**
  • I found a way how to fix it after I debug. It was only using the last used row, because there was nothing to check that I want to edit only the current row. That's why I decide to use `at`
  • ```Python
  • for index, row in priceListTest.iterrows():
  • #print(index,row)
  • def get_slices(n, sizes, n_digits=11):
  • for size in sizes:
  • n_digits -= size
  • val, n = divmod(n, 10 ** n_digits)
  • yield f'{val:0{size}}'
  • n = row['Парт номер']
  • newVar = (' '.join(get_slices(n, [2, 2, 1, 3, 3])))
  • priceListTest.at[index,['New Value']] = newVar
  • print("after changes")
  • print(priceListTest)
#2: Post edited by user avatar sfrow‭ · 2021-11-08T19:15:26Z (over 2 years ago)
  • Hi, I have one more question, because I do something wrong. If you notice the last column new Value is getting only from the last row. Which is ending with 416. Somehow I want inside of this for to update and create the new column to contain for each row the updated pattern.
  • ![Image alt text](https://software.codidact.com/uploads/1CxdEXsPMXCqH8HGU9aPAJLF)
  • Hi, I have one more question, because I do something wrong. If you notice the last column new Value is getting only from the last row. Which is ending with 416. Somehow I want inside of this for to update and create the new column to contain for each row the updated pattern.
  • ![Image alt text](https://software.codidact.com/uploads/1CxdEXsPMXCqH8HGU9aPAJLF)
  • I found a way how to fix it after I debug. It was only using the last used row, because there was nothing to check that I want to edit only the current row. That's why I decide to use `at`
  • ```Python
  • for index, row in priceListTest.iterrows():
  • #print(index,row)
  • def get_slices(n, sizes, n_digits=11):
  • for size in sizes:
  • n_digits -= size
  • val, n = divmod(n, 10 ** n_digits)
  • yield f'{val:0{size}}'
  • n = row['Парт номер']
  • newVar = (' '.join(get_slices(n, [2, 2, 1, 3, 3])))
  • priceListTest.at[index,['New Value']] = newVar
  • print("after changes")
  • print(priceListTest)
#1: Initial revision by user avatar sfrow‭ · 2021-11-08T18:21:54Z (over 2 years ago)
Hi, I have one more question, because I do something wrong. If you notice the last column new Value is getting only from the last row. Which is ending with 416. Somehow I want inside of this for to update and create the new column to contain for each row the updated pattern.
![Image alt text](https://software.codidact.com/uploads/1CxdEXsPMXCqH8HGU9aPAJLF)